I am a s9keaz64amlh user.
I want to inquire about MSCAN.
I use 'MSCANDRIVER' provided by nxp.
CAN communication was confirmed.
So I try to do what I want, but I'm not good at it.
I try to run the motor when I get a certain CAN ID.
For example, I want to make a program where 0X81 is motor operation and 0X82 is motor reverse operation.
However, after writing the code as below, the specific CANID cannot be identified.
int main (void)
{
UINT8 err_status;
UINT32 a;
UINT8 data [7] = {6, 0, 0xff, 0, 0xff, 0, 0xff};
UINT8 Rdata [8];
UINT8 buffer_status [2];
Init_CAN (0, FAST);
Config_CAN_MB (0, 2, RXDF, 1);
GPIO_Init ();
Clk_Init ();
FAIL_APPLY ();
MSCAN_ModuleEn ();
GPIOB_PDDR | = (1 << 16);
GPIOB_PCOR = (1 << 16);
EnableInterrupts;
for (;;) {
}
}
What should I modify in this code and how do I set a specific id?
I would appreciate it if you let me know.
if( a == 0x81){
motor operation;
}
else if (a ==82){
motor reverse operation;
}
I want to know a function or variable that sets a == 0x81 or 0x82.
Hi Jong,
To identify from where is received the CAN message one way could be to set a Mailbox with each ID that you mention, this could help you identify from which ID came the message.
Best Regards,
Alexis Andalon