Hello,
I have been trying to set the Timer3 in the CC2530 using the SmartRF05 board to generate a periodic interrupt in Modulo Mode every time an overflow occurs. However even though I have applied the settings step by step as specified on the User Guide, it never generates the interrupt, in which all I do is toggle an LED (I monitor this signal with an oscilloscope). I am using IAR Workbench 8051. Could you please take a look at the code and tell me what exactly am I missing?
#include "iocc2530.h"
#include "hal_board.h"
#include "hal_led.h"
#define T8BIT_TICK_FREQ_DIV128 7
#define T8BIT_MODE_MODULO 2
#define T3_COUNT_VALUE 0x7F
#ifndef SH
#define SH(n,m) (n << (m))
#endif
void main(void)
{
// Initalise board peripherals
halBoardInit();
/***************************************************************************
* Timer 3
*/
// Connect timer3 interrupt function to corresponding interrupt vector
//Timer3IntConnect(&Timer3AccIsr);
//HAL_ISR_FUNCTION(T3_ISR,T3_VECTOR)
/*Start Timer*/
T3CTL |= 0x10;
/*Set Timer Clock Frequency */
T3CTL &= ~0xE0;
T3CTL |= SH(T8BIT_TICK_FREQ_DIV128,5);
/* Set Mode */
T3CTL &= ~0x03; //Start Timer
T3CTL |= T8BIT_MODE_MODULO; //Set Modulo Mode
/*Enable OverFlow Interrupt Mask*/
T3CTL |= 0x08;
/*Disable OverFlow Interrupt*/
T3CTL &= ~0x08;
/* Set Comp Value (If necessary*/
T3CC0 = T3_COUNT_VALUE;
/*Enable Timer3 Overflow Interrupt*/
TIMIF &= ~0x01; // Clear Flag
IEN1 |= 0x08; // T3IE = 1
// Enable Global Interrupts
EA = 1;
// Main loop
while (1) { }//while
}//Main
HAL_ISR_FUNCTION(T3_ISR,T3_VECTOR)
{
halLedToggle(1);
}