2626// every millisecond, and we configure the timer to reset to 0 when it reaches a count value
2727// corresponding to one millisecond of time. Finer timing resolution can be obtained by
2828// combining the software-managed millisecond counter with the timer value.
29+ //
30+ // The system tick uses the "12" half of the timer, and the PRU1 (TODO) uses the "34" half.
2931const uint32_t auxclk_freq_hz = 24000000 ;
3032const uint32_t timer_ms_period = (auxclk_freq_hz / 1000 ) - 1 ;
3133
@@ -39,8 +41,8 @@ volatile uint32_t systick_ms = 0;
3941 */
4042void systick_isr_C (void ) {
4143 /* Clear the interrupt status in AINTC and in timer */
42- IntSystemStatusClear (SYS_INT_TINT34_0 );
43- TimerIntStatusClear (SOC_TMR_0_REGS , TMR_INTSTAT34_TIMER_NON_CAPT );
44+ IntSystemStatusClear (SYS_INT_TINT12_0 );
45+ TimerIntStatusClear (SOC_TMR_0_REGS , TMR_INTSTAT12_TIMER_NON_CAPT );
4446
4547 ++ systick_ms ;
4648
@@ -54,15 +56,15 @@ void systick_isr_C(void) {
5456 */
5557void systick_suspend (void ) {
5658 /* Disable the timer interrupt */
57- TimerDisable (SOC_TMR_0_REGS , TMR_TIMER34 );
59+ TimerDisable (SOC_TMR_0_REGS , TMR_TIMER12 );
5860}
5961
6062/**
6163 * Enable the timer and therefore the systick
6264 */
6365void systick_resume (void ) {
6466 /* Enable the timer interrupt */
65- TimerEnable (SOC_TMR_0_REGS , TMR_TIMER34 , TMR_ENABLE_CONT );
67+ TimerEnable (SOC_TMR_0_REGS , TMR_TIMER12 , TMR_ENABLE_CONT );
6668}
6769
6870/**
@@ -77,23 +79,22 @@ void pbdrv_clock_init(void) {
7779
7880 /* Set up the timer */
7981 TimerConfigure (SOC_TMR_0_REGS , TMR_CFG_32BIT_UNCH_CLK_BOTH_INT );
80- TimerPreScalarCount34Set (SOC_TMR_0_REGS , 0 );
81- TimerPeriodSet (SOC_TMR_0_REGS , TMR_TIMER34 , timer_ms_period );
82+ TimerPeriodSet (SOC_TMR_0_REGS , TMR_TIMER12 , timer_ms_period );
8283
8384 /* Register the Timer ISR */
84- IntRegister (SYS_INT_TINT34_0 , systick_isr_C );
85+ IntRegister (SYS_INT_TINT12_0 , systick_isr_C );
8586
8687 /* Set the channel number for Timer interrupt, it will map to IRQ */
87- IntChannelSet (SYS_INT_TINT34_0 , 3 );
88+ IntChannelSet (SYS_INT_TINT12_0 , 3 );
8889
8990 /* Enable timer interrupts in AINTC */
90- IntSystemEnable (SYS_INT_TINT34_0 );
91+ IntSystemEnable (SYS_INT_TINT12_0 );
9192
9293 /* Enable the timer interrupt */
93- TimerIntEnable (SOC_TMR_0_REGS , TMR_INT_TMR34_NON_CAPT_MODE );
94+ TimerIntEnable (SOC_TMR_0_REGS , TMR_INT_TMR12_NON_CAPT_MODE );
9495
9596 /* Start the timer */
96- TimerEnable (SOC_TMR_0_REGS , TMR_TIMER34 , TMR_ENABLE_CONT );
97+ TimerEnable (SOC_TMR_0_REGS , TMR_TIMER12 , TMR_ENABLE_CONT );
9798}
9899
99100uint32_t pbdrv_clock_get_us (void ) {
0 commit comments