Hi all,
I'm having a problem with something that should be simple: getting a Timer5 ISR to fire on a C8051F1380 MCU.
This being my first time using 8051 (I normally use PICs or Cypress PSoC5 controllers) I'm not sure what I'm doing wrong.
The Timer SFRs are set up as follows:
#define SFR_TMR5CN 0xC8 SFR (TMR5CN, 0xC8); // Timer/Counter 5 Control // TMR5CN 0xC8 (Page F) SBIT (TF5H, SFR_TMR5CN, 7); // Timer5 high byte overflow flag SBIT (TF5L, SFR_TMR5CN, 6); // Timer5 low byte overflow flag SBIT (TF5LEN, SFR_TMR5CN, 5); // Timer5 low byte interrupt enable SBIT (T5CE, SFR_TMR5CN, 4); // Timer5 capture enable SBIT (T5SPLIT, SFR_TMR5CN, 3); // Timer5 split mode enable SBIT (TR5, SFR_TMR5CN, 2); // Timer5 on/off control SBIT (T5CSS, SFR_TMR5CN, 1); // Timer 5 Capture Source select SBIT (T5XCLK, SFR_TMR5CN, 0); // Timer5 external clock select #define INTERRUPT_TIMER5 20 // Timer5 Overflow
I'm setting up the timer as follows for a 48MHz SYSCLK (divided by 12) in a Timer_Init() function:
//Timer5 - 10ms //Clock = SYSCLK/12 //65536-40000 = 45536 -> 0xB1E0 T5XCLK = 0; //SYSCLK/12 TR5 = 0; TMR5RLH = 0xB1; TMR5RLL = 0xE0; TMR5H = 0xB1; TMR5L = 0xE0; EIE2 |= 0x20; //Enable Timer5 Interrupt
I am enabling the timer on a button press and can confirm the button press code is firing correctly:
TR5 = 1;
The ISR itself is meant to count 5 seconds to set a flag for for an OSD timeout before disabling the timer:
void Timer5_ISR(void) interrupt INTERRUPT_TIMER5 { static WORD osd_5s_counter = 0; TF5H = 0; //Timer 5 OF Flag is NOT cleared by hardware if (++osd_5s_counter >= OSD_5S_COUNT){ osd_5s_counter = 0; TR5 = 0; OSD_Display = 0; TMR5RLH = 0xB1; TMR5RLL = 0xE0; TMR5H = 0xB1; TMR5L = 0xE0; } else { TR5 = 1; } }
Any thoughts/advice is greatly appreciated. Not sure what I'm getting wrong here.
Thanks in advance!
Hi Andy,
Yes that makes sense.
Thread has been created on the SI Labs forum:www.silabs.com/.../issues_using_timer5onc8051f138xisrnotfiring-jYjo