| ??? 10/01/07 14:03 Read: times |
#145173 - CC2430 Timer1 strange behaviour |
Hi,
I have been cuddling around with TIMER1 in CC2430. I found some strange behaviour to the code that I wrote. I am using interrupt TIMER1 and here is some of the codes: #include "RF04EB.h" #include "hal.h" #include "cul.h" WORD BRUSHLESS1, BRUSHLESS2; BOOL fBrushless; #pragma vector=T1_VECTOR __interrupt void T1_Interrupt_handler(void){ if (fBrushless) { halSetTimer1Period(BRUSHLESS1); fBrushless = FALSE; P1_3 = 1; } else { halSetTimer1Period(BRUSHLESS2); fBrushless = TRUE; P1_3 = 0; }; } void main(void) { SET_MAIN_CLOCK_SOURCE(CRYSTAL); INT_GLOBAL_ENABLE(INT_ON); // Global Interrupt enabled INT_ENABLE(INUM_T1, INT_ON); // Interrupt TIMER1 enabled //TIMER1_INIT(); T1CTL = 0x02; T1CCTL0 = 0x44; //***** THIS IS THE STRANGE PART!!! T1CCTL1 = 0x00; T1CCTL2 = 0x00; TIMIF &= ~0x40; TIMER1_ENABLE_OVERFLOW_INT(TRUE); // TIMER1 Overflow Mask BRUSHLESS1 = 1000; BRUSHLESS2 = 1000; TIMER1_RUN(TRUE); // Start TIMER1 IO_DIR_PORT_PIN(1, 3, IO_OUT); // P1.0 as output P1SEL &= ~0x08; // general purpose I/O //do { //} while (1); If I change line with T1CCTL0 = 0x44 to: T1CCTL0 = 0x04; T1CCTL0 |= 0x40; it compiles just fine but it the interrupt doesn't work. And another strange behaviour also happens when I change the value of BRUSHLESS1 or BRUSHLESS2 around 30000. What do you guys think might go wrong in my code? Or is there any setup that I should do in the compiler options? Thanks, Ekawahyu Susilo |
| Topic | Author | Date |
| CC2430 Timer1 strange behaviour | 01/01/70 00:00 | |
| How to use the 'Insert Code' button | 01/01/70 00:00 | |
| Ok, I post another in pre-formated one ;-) | 01/01/70 00:00 | |
| Brushless1 & 2 | 01/01/70 00:00 | |
| IAR | 01/01/70 00:00 | |
| Linker | 01/01/70 00:00 | |
| limit values | 01/01/70 00:00 | |
| limit values | 01/01/70 00:00 | |
| Why do you suspect the Linker?? | 01/01/70 00:00 | |
| Problem solved! | 01/01/70 00:00 | |
| That indicates a flaw in your code! | 01/01/70 00:00 | |
| Understaning C Compiler Optimisations | 01/01/70 00:00 | |
| Buggy compilers. | 01/01/70 00:00 | |
If you fully understand the issues | 01/01/70 00:00 |



