Hi, I need a simple timer that interrupts every second. I'm trying to use the code from the sleep timer, but it isn't working. this device is the PRX, so i don't want it go to sleep. what am i getting wrong? Thanks! Mahesh
void mcu_init(void) {
P0DIR |= 0x13; // bxxx1-xx11. RXD = P04, XOSC32K inputs= P01, P02. Set bits to 1 for input.
P0DIR &= 0xF3; // ~0x0C, or 0xF3: bxxxx-00xx. TXD = P03, LED = P02. Set bits to 0 for output.
P1DIR |= 0x02; // bxxxx-x1xx. ADC AIN0 = P12. Set bit to 1 for input.
OPMCON = 0x00; // open latch
//OPMCON |= 0x02; // bxxxx-xx0x is latch open, bxxxx-xx1x is latch closed.
}
void set_timer(uint16_t duration) {
hal_rtc_start(false);
hal_clklf_set_source(HAL_CLKLF_RCOSC32K);
hal_rtc_set_compare_mode(HAL_RTC_COMPARE_MODE_0);
//hal_rtc_set_compare_value(*sleep); // e.g. 0x7FFF, 0xFFFF, etc.
hal_rtc_set_compare_value(duration);
hal_rtc_start(true);
}
main() {
mcu_init();
set_timer(0x7FFF);
while(1);
}
void wakeup_tick() interrupt INTERRUPT_TICK {
timestamp++;
}