...
Before main:
A place to declare constants, additional function prototypes, global variables
Inside main outside the while(1) loop:
A place for any setup or functions you want to run once before the loop
Inside the while loop:
Code that will be run repeatedly and often contains the main system behavior
Please add the following line here at the end of the user code section to ensure the MCU doesn’t overload the ADC:
HAL_Delay(10);
After main:
Where you write functions that match any function prototypes you have added
...
To submit your work for review, create a pull request of your fork against the UWARG/embedded-bootcamp repository. Name your pull request Bootcamp: YOURNAME
. Tell the responsible team lead that you've completed the bootcamp in the #Bootcamp
Discord channel and they will have someone review your submission. You may be asked to revise some things.
General Hints
For PWM, you will need to use timer 1 to create a PWM signal. The signal should be at 50Hz, with an on-time ranging from 1ms - 2ms. To achieve this frequency, you will need to change the prescaler and period in
tim.c
. Note that the input clock frequency is 48 MHz. To change the duty cycle, you will need to set the compare register using the HAL library APIs.Look at the HAL_ADC_, HAL_TIM_ , and __HAL_TIM_ functions to access the timers and ADCstimer. The HAL User Manual will be particularly useful here.
For SPI communication look at the SPI IO operation function in the HAL User Manual.
The electrical schematic is useful for determining which pins should be configured to which peripheral.
...