Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

communication between 2 uCs

Status
Not open for further replies.

impakt

Member level 4
Member level 4
Joined
Dec 19, 2005
Messages
68
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,286
Activity points
1,799
Hello,
I have to write a piece of code for the following situation: there are 2 microcontrollers (a failsafe uC and a main uC) and they comunicate through SPI; the main uC receives at every 20ms frames on CAN; the main uC must send to the failsafe uC the intact frame received on CAN, while it (main uC) is in HP. The used programming language is C. Question: how could I do that, in embedded C? All I need is an algorithm.
I came out with an algorithm, but I do not know if it's ok, so I need the opinion of someone that has experience:

boolean flag1;// flag to be set to 1 if frame is received on CAN
if (HP) // if in HP - could while(HP) be used?
{
if(flag1) //if a frame is received
{
send_failsafe(can_frame); //send the frame to second uC
flag1=0; //reset the flag
}
else
{
// do nothing; wait for the next frame
}
} //this piece of code is executed every 10ms, and the frames are received every //20ms, so that's why the flag must be reseted, so that the same frame is not to be //sent twice
So, what do you think? any suggestions?
Thank you for support!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top