Hi,
I am using two CC1110 devices in PM1 to communicate.
I am having issues with the device which is receiving first and then transmitting the packet. After tx this device goes to sleep(PM1) where I am incrementing a counter by one. But when I print the value of this counter, it is getting incremented by more than 1.
Following is the code:
volatile int8_t count=1;
main(){
while(1){
Rx mode on
Wait for receiving the packet //using Timer4
Tx a packet
printf("%d ", count);
sleep(1s);
}
}
sleep(int_8t duration){
if(MRFI_GetRadioState()==IOCTL_ACT_RADIO_AWAKE)//!= MRFI_RADIO_STATE_OFF)
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP,0);
IEN2 &= ~0x01;
BSP_SET_MAIN_CLOCK_XOSC32K();
STIE=1;
bsp_PowerMode(POWER_MODE);
BSP_SET_MAIN_CLOCK_XOSC();
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE,0);
IEN2 |= 0x01; // Enable RF interrupt
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXIDLE, 0);
}
BSP_ISR_FUNCTION( BSP_SleepIsr, ST_VECTOR)
{
BSP_DISABLE_INTERRUPTS();
IRCON = 0; // Clear MCU flag
WORIRQ = 0x12; // Clear ST local flag
STIE = 0; // Disable Sleep Timer interupt.
SLEEP &= ~0x03; // Clear sleep mode bits
count++; //increment the counter
BSP_ENABLE_INTERRUPTS();
}
Following is the result:
1 16 31 47 48 64 65 81 100 101 148 149 196 197 216 217 221 222 223..
Now if I turn off the device which is doing Tx first and then Rx, then counter starts incrementing by one.
Can anyone explain this strange issue?
Thanks