CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

INT_SSP and INT_RDA

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Linuxbuilders



Joined: 20 Mar 2010
Posts: 193
Location: Auckland NZ

View user's profile Send private message

INT_SSP and INT_RDA
PostPosted: Fri Jul 24, 2015 1:48 am     Reply with quote

Hey,
I know there was lots about that but not about this one I feel Smile

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: 19548

View user's profile Send private message

PostPosted: Fri Jul 24, 2015 2:13 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jul 24, 2015 2:23 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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