|
|
View previous topic :: View next topic |
Author |
Message |
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
INT_SSP and INT_RDA |
Posted: Fri Jul 24, 2015 1:48 am |
|
|
Hey,
I know there was lots about that but not about this one I feel
I do have RDA and i2C active, i2c works well, RDA too but:
1. When I send a string to RDA it does not process it, I can see that it did jump into INT and out of it, the string is loaded correctly into var[]
And it sits there, then when I send i2c then SSP int activates then it does process RDA ???
I do this:
Code: |
#INT_RDA
void comms_rda(VOID)
{
BYTE c = 0;
output_high (STATUS);
rda1_RX_busy = 1;
c = getc();
rda1capture[rda1_counter] = c; // load CHAR into temporary buffer
IF (rda1_counter == 21)
{
IF ((rda1capture[0] == 0x01) && (rda1capture[21] == 0x01))
{
MSG_READY = 1;
memcpy(message,rda1capture,22);
}
rda1_counter = 0;
}
else
{
IF ((c != 0x01) && (rda1_counter == 0))
{
rda1_counter = 0;
}
else
{
rda1_counter++; // advance the buffer
}
}
IF (rda1_counter > 21)
{
rda1_counter = 0;
}
rda1_RX_busy = 0; // RX free
irda = 1;
output_low (STATUS);
} //VOID |
then in main loop
Code: | if (MSG_READY == 1) //RX message is ready to process
{
PROCESS_MSG();
MSG_READY = 0;
} |
SSP and RDA code works perfectly well in i2c master mode, but in slave it is like ssp holds rda, which is strange because data is received correctly there but it looks like VARS (MSG_READY = 1; irda = 1;) are not released and sits in ZERO state.
Is there anything which could make VARS not to change the state?
Those are global int vars.
Thnx _________________ Help "d" others and then you shell receive some help from "d" others. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19488
|
|
Posted: Fri Jul 24, 2015 2:13 am |
|
|
What chip?.
What compiler version?.
What CPU clock rate?.
What I2C baud rate?.
Post your UART setup, and your SPI setup.
Post your SSP interrupt handler.
Then as a general comment, rethink.
Using memcpy, inside an ISR, is not a good thing to do. It is very slow.
Either use a circular buffer, or for a linear data block, have space for two blocks. with two pointers.
One used by the ISR, and one by the main code.
As soon as a block is complete, just set the flag, and swap the pointers.
This way you don't have to physically move the data. The code outside talks to the version the interrupt is not using.
Remember also that if you are using any string operations on the message, you should be adding a null terminator. |
|
|
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Fri Jul 24, 2015 2:23 am |
|
|
Found the bug, nothing wrong with code. Looping while outside of main with watchdog reset.
Thnx for help. _________________ Help "d" others and then you shell receive some help from "d" others.
Last edited by Linuxbuilders on Fri Jul 24, 2015 3:14 am; edited 1 time in total |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|