Hi Everyone,
I am working on an RF application using the MSP430g2553. I have already configured a USCI_AO UART for terminal debugging purposes and am using the "tiny printf" function I found on the launchpad site to print to the terminal.
http://www.msp430launchpad.com/2012/06/using-printf.html
I now have a need for another "serial interface" to receive data coming from my RF IC, preferably on port 2 to avoid conflicts with the current UART configuration.
I have decoded data coming out of my RF IC which I want to pass along to the MSP430 and store into memory to be used later (ie. print to the screen for testing, verifying data, etc.).
The serial data has no start or stop bits, it is simply the raw decoded RF information (128bits repeating themselves cyclically).
The CLK for the serial data has a period of approximately 250us, so we need to check the DATA line at least every 250us to see if it is a high or a low and store this information in memory.
I found a nice example of a 9600baud bit banged UART on the MSP430 also on the launchpad site:
http://www.msp430launchpad.com/2010/08/half-duplex-software-uart-on-launchpad.html
I had thought about modifying this to use ports on P2 however start and stop bits are not needed and the timing delays for the baud rate certainly don’t match the timing that I require so it seems like this would be way more work than I am prepared to attempt at this point.
It is important that the data is accurate so I had also thought about embedding interrupts, although If I can get around this without using multiple interrupts it would be nice. I am assuming that the only way that could be achieved reliably would be by comparing the CLK bits to the DATA bits using another input port.
If I were to go about it using timing interrupts only, this is the way I thought about doing it:
/*
I can implement a timing interrupt that is activated every 250us and check the status of the DATA bit (Port2.7) to see if it is high or a low and then store a ‘1’ or a ‘0’ in the global char array: “byte_decode[127] ”.
Polling only 1 bit gives a high probability for “framing errors” so I’m attempting to poll both the Data and CLK bits.
*/
volatile char byte_decode[8];
volatile unsigned int index2 = 0;
CLK_BIT = BIT5;
DATA_BIT = BIT7;
Void Main()
{
//Do_something
}
#pragma vector = TIMER_A0_VECTOR
__interrupt 250us_interrupt
{
If((P2IN && CLK_BIT) != 0)
{
If((P2IN && DATA_BIT) == 0)
Byte_decode[index2] = ‘0’;
Else()
Byte_decode[index] = ‘1’;
Index2++;
}
}
A problem I am running into is that every time the timer interrupt completes it goes into low power mode and the main function is unable to perform a check to see if the buffer/char array is full or print the array to the terminal.
Could somebody maybe help me out with this or get me headed more in the right direction?
Thanks,
Corin