2024-12-18 05:57 PM
Hi All,
I have been meaning to post one of my projects to the forum for a while to help others with some of the trickier feature of the STM32 processors, but it is difficult as full project with TouchGFX are rather large. I tried Git Hub, but it said No to the number of files so I opted for DropBaox with a link:
If it asks for a password i is
greenhouse1924
This file is a zip of the project and must be extracted to a folder c:\Eng to work. The project workspace is included:
Ignore the first folder that is just the Github stuff. The bottom three files are configs for ST Studio which I still use because the new monitor program is a dog.
The project was generated using TouchGFX 4.24.0 and CubeIDE Version: 1.17.0. I used CubeMX in a dummy project to generate some of the peripheral intialisation code. I don't use CubeMX interactively within the project because it sticks everything in the main.c file which makes it a dog to manage. I also don't like the way it sticks all the pin allocations, interrupts etc in one big msp file. If I make a project from scratch with no TouchGFX then I set CubeMX to produce individual peripheral files. TouchGFX doesn't provide this option.
The project provides:
- TouchGFX GUI
- Ethernet with SNTP and ICMP (Adam Berligers version posted in this forum with a few of my own mods.)
- The real time clock set by the ethernet time.
- ADC's in circular DMA mode with union data structures to ease debugging
- PWM Timer (TIM12) to drive a H-Bridge with enable inputs
- Uses ITCM and DTCM memory for stack, base heap and selected functions
- CubeIDE is set up with SWV and FreeRTOS aware debugging with task counters and stack monitoring
- Debug Console using SVW ITM outputs
- Timer driven control task using task notify (not semaphores)
- Modified interrupt service routine files to avoid call to HAL interrupt handling for time critical interrupts
- A file called osPriorities.h to consolidate operating system interrupt and task priorities instead of having them sprinkled throughout the code.
- A version control module version.c and version.h which are forced to compile each build using prebuild:
C:ST\STM32CubeIDE_1.15.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.make.win32_2.1.300.202402091052\tools\bin\busybox.exe touch version.c
- Set memory to Close Coupled Memory (CCM) to manage CCM memory allocation
- Custom circular buffers FIFO for data logging and ehternet data transfer management (not yet implemented). I guess I could use FreeRTOS queues, but I like mine better.
I haven't put the interrupt vectors in ITCM as I'm not sure how to do this, but I will get around to this eventually.
The control algo code was generated automatically, but it only works for my application so you can replace the two algorithms, ghTempControlAlgo and DoorControl functions with your own control algo's.
The project is incomplete as I haven't implemented the ethernet data transfer or the alarm system, but the project as is is now running the greenhouse albeit with no data link.
I designed a custom interface board that the discovery plugs into. It has an interface to an infineon based H-Bridge that drives the linear actuator for the greenhouse vent, a couple of temperature inputs using the LM135 abs temp sensor and six digital outputs. The bosrd was developed in KiCad and a zip is attached. SEEED Studio did a nice job on the PCB, but I assembled the boards myself. NOTE: Use the TI Isolation Chip ISO7760DW not the one shown in the schematic as the schematic shows a bi-directional version.
I hope people find the project useful and if they have any improvements they can think of to let me know.
Kind Regards
Rob