Go Down

Topic: I2C - Problem with onRequest, onReceive (Read 342 times) previous topic - next topic

mzahor

Jul 15, 2013, 03:03 pm Last Edit: Jul 15, 2013, 03:07 pm by mzahor Reason: 1
Hi,

I've problem with IDE 1.5.2 and Arduinu DUE.

My program size: 304,492 bytes
Free RAM: cca 70kB [ not 100% ] - used some code to get this number

Problems started after I've added Wire1 as I2C Slave and using :
- onRequest
- onReceive

The same problem with Wire and Wire1.
 
Since that program freezes at the same location - not in I2C callback [ I think ] but while drawing to TFT display.

I'm thinking about some Stack issue but can't [ don't know how ] investigate it more.

 Wire1.begin(NET_MODULE_WIRE_ADDRESS);
 Wire1.onRequest(onRequestHandler);
 Wire1.onReceive(onReceiveHandler);


void  onRequestHandler(void)
{
 byte val ;
 switch (cmd_received)
 {
   //je queue prazdna ?
   case CMD_QUEUE_EMPTY:
   
     Wire1.write(RQX_HEADER);
     Wire1.write(queue[0].empty);
     
   break;

}}

//receive command from network arduino UNO
void onReceiveHandler(int howMany )
{

 if(Wire1.available())
 {
   cmd_received = Wire1.read();
 }

 
}

Go Up