Hi all
With the below code and the ez430-RF2500, I can simulate a simple wireless communication. However I have two questions and hopefully somebody can answer me.
1. The code only works randomly, when I press the button to send, NOT every single time the RED LED is on, I have checked that the button is rebounded, what is the possible reason behind please?
2. In the main loop, I have put the device into LPM4 sleep mode, and I NEVER exit this mode, so why can the SPI communication still work? Does it mean that with the below code, once the device is entered into sleep mode, it stays in the sleep mode forever but is still able to provide SPI clock for communication?
#include "include.h"
#include "mrfi.h"
#include "radios/family1/mrfi_spi.h"
int main(void)
{
BSP_Init();
P1REN |= 0x04;
P1IE |= 0x04;
P1IFG &= ~0x04;
MRFI_Init();
mrfiSpiWriteReg(PATABLE, 0xFE);
mrfiSpiWriteReg(PKTCTRL0,0x41);
MRFI_WakeUp();
MRFI_RxOn();
__bis_SR_register(GIE+LPM4_bits);
}
void MRFI_RxCompleteISR()
{
uint8_t i;
P1OUT ^= 0x02;
mrfiPacket_t packet;
MRFI_Receive(&packet);
char output[] = "111222333444555666777888\r\n";
for (i=9;i<=packet.frame[0];i++) {
output[i-9]=packet.frame[i];
}
TXString(output, (sizeof output));
}
#pragma vector=PORT1_VECTOR
__interrupt void Port_1 (void)
{
//P1IFG &= ~0x04;
P1IFG |= 0x04;
mrfiPacket_t packet;
packet.frame[0]=8+24; //8 bytes header, 24 bytes payload
//Channel 1
packet.frame[9] = 'a';
packet.frame [10] = 'a';
packet.frame [11] = 'a';
//Channel 2
packet.frame [12] = 'b';
packet.frame [13] = 'b';
packet.frame [14] = 'b';
//
//Channel 3
packet.frame [15] = 'c';
packet.frame [16] = 'c';
packet.frame [17] = 'c';
//Channel 5
packet.frame [18] = 'd';
packet.frame [19] = 'd';
packet.frame [20] = 'd';
//Channel 6
packet.frame [21] = 'e';
packet.frame [22] = 'e';
packet.frame [23] = 'e';
//Channel 7
packet.frame [24] = 'f';
packet.frame [25] = 'f';
packet.frame [26] = 'f';
//Channel 8
packet.frame [27] = 'g';
packet.frame [28] = 'g';
packet.frame [29] = 'g';
//Channel 8
packet.frame [30] = 'h';
packet.frame [31] = 'h';
packet.frame [32] = 'h';
MRFI_Transmit(&packet, MRFI_TX_TYPE_FORCED);
P1OUT ^= 0x01;
}