Skip to content

Bootcamp: Shayne Yang - #324

Closed
ShayneYurnYang wants to merge 3 commits into
UWARG:masterfrom
ShayneYurnYang:master
Closed

ShayneYurnYang wants to merge 3 commits into
UWARG:masterfrom
ShayneYurnYang:master

Conversation

@ShayneYurnYang

Copy link
Copy Markdown

No description provided.

Updated pin configurations for through STMCubeIDE
Initialize SPI-based ADC reads and drive a 50Hz PWM servo output from ADC values. Set chip-select (PA4) HIGH during init to avoid ADC desync, then start TIM1 PWM. In the main loop send a 3-byte SPI request, reconstruct a 10-bit ADC value from the response, map it linearly to timer compare counts (3200-6400) for 1–2 ms pulse width, and update TIM1 CH1. Also throttle loop with HAL_Delay(10). Adjust TIM1 period from 64000 to 63999 in both tim.c and the .ioc to correct the timer's autoreload value.
Add SERVO_MIN_PULSE, SERVO_MAX_PULSE and SERVO_PULSE_RANGE macros and replace hard-coded 3200/6400 values in main.c. The ADC-to-PWM interpolation now uses the named constants (with UL suffix) to compute compare_val, improving clarity and ensuring correct unsigned arithmetic when mapping 10-bit ADC values to timer counts.
@EemanAleem EemanAleem closed this Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants