Closed annikaolson closed 4 months ago
Next step is @codecubepi manually resolving the merge conflicts in the .bd
file, then we merge this and test the v1.3-staging
branch in the lab.
I am going to close this PR, since its changes have been implemented in #397 (specifically commit bd8ae30).
This PR addresses issues #391, #314, and #377. Previously, the scheduler ISR was triggered by the SysTick private timer in
timer.c
. This was initialized to a predetermined control rate, with the default at 10kHz - in other words, the scheduler would fire every 100 μs. The goal here was to instead synchronize the scheduler with the PWM carrier.Two Scheduler Modes
There are now two modes for the scheduler source/functionality. This is user-configurable in
usr/user_config.h
byUSER_CONFIG_ISR_SOURCE
.Mode 0
The scheduler runs the tasks (i.e. ISR is called to move out of the idle state) on every "trigger" assertion.
all_done
. The default (intiming_manager.h
) is 10, which triggers the ISR every 10 carrier lows, leading to a default control rate of 10kHz.The user can change the PWM event qualifier (carrier high, low, or both) and the user ratio to change the control frequency of the tasks.
Mode 1
When none of the sensors are enabled, this mode operates the same as mode 0. When any sensors are enabled, the scheduler is synchronized with the sensors. The ISR is called when all of the sensors have completed their acquisition cycles (positive edge of
all_done
).FPGA Changes
Sensors
trigger
signal is now based onall_done
. For this fix to work, all of the sensors needed to start theirdone
signal at 1Timing Manager
all_done
signal, which would call an ISR in the timing manager driver to update the stats once all the sensors had completed their acquisition. Now, the interrupt is asserted based on the modes mentioned above:https://github.com/Severson-Group/AMDC-Firmware/blob/47d34ecf31241087504ffe84d59e5e3b1ca63290/ip_repo/amdc_timing_manager_1.0/src/timing_manager.v#L207-L223
C-Code Changes
cmd_hw.c
To report the time, the code before was directly calling
timing_manager_get_time_per_sensor()
, but it is now using the statistics struct for each sensor. It's pulling the value (which is the most recent value), but the stats also hold the max, min, and mean value for each sensor time.timing manager changes
slv_reg4
in the FPGA.scheduler changes
timer.c
andtimer.h
could be removed. The timing manager ISR is the only one used, so the code inscheduler_timer_isr()
was moved toscheduler_tick()
which increments the elapsed time and moves it out of the idle state, unpausingscheduler_run()
and runs the tasks.log
task was using the defined SysTick frequency from the scheduler. This means that it should be happening every time the ISR is called, or as often as possible, so the interval is set to 0. https://github.com/Severson-Group/AMDC-Firmware/blob/47d34ecf31241087504ffe84d59e5e3b1ca63290/sdk/app_cpu1/common/sys/scheduler.c#L190-L192 Thus, the elapsed time since the last run will always be greater than 0, and this task will run every time as desired.Block Design Changes
hier_timers
IP. This hierarchy contains two control timer modules that are connected toIRQ_F2P
of the processing system - they do nothing, and aren't needed!sched_isr
- this is connected toIn0
of a 16-bit concat block.In1
is a 15-bit port connected to a const block with value of 0. This concat block output should be sent to theIRQ_F2P
port of the processing system. The LSB (IRQ_F2P[0]
) is the interrupt with ID 61.