Hi everyone.
I've problem to ask you guys.
I'm using lm-3s9d96 and implemented a CAN library to handle receiving and sending messages.
I'm having a problem when I try to receive messages.
I've 4 slave devices on the bus that send data with 2007, 2017, 2027 and 2037 message ids. The devices send with 40 ms delay. I mean when I send a request to any device, that will response after 40 ms. I'm trying to get these datas consequently by looking at the receive interrupts for individual message objects.
But I'm having problems.
But first, let me show you my codes:
tCANMsgObject g_gonderici_can_mesaj_objesi; // sender message object
tCANMsgObject g_alici_can_mesaj_objesi; // receiver message object
main.c
{
Im_CANAyarla(CAN0, PA6_PA7, 250000); // INITIALIZE CANBUS, it work fine, no problem with that.
while(1)
{
ImSMO15_MesIstekGonder(CAN0, 1, &g_gonderici_can_mesaj_objesi, 2);
ImSMOI15_MesafeAl(CAN0, 2, &g_alici_can_mesaj_objesi, 2);
if(g_s_smo15_1_verisi_geldi == 1)
{
ImSMO15_MesIstekGonder(CAN0, 1, &g_gonderici_can_mesaj_objesi, 1);
ImSMOI15_MesafeAl(CAN0, 2, &g_alici_can_mesaj_objesi, 1);
g_s_smo15_1_verisi_geldi = 0;
}
if(g_s_smo15_2_verisi_geldi == 1)
{
ImSMO15_MesIstekGonder(CAN0, 5, &g_gonderici_can_mesaj_objesi, 3);
ImSMOI15_MesafeAl(CAN0, 6, &g_alici_can_mesaj_objesi, 3);
g_s_smo15_2_verisi_geldi = 0;
}
if(g_s_smo15_3_verisi_geldi == 1)
{
ImSMO15_MesIstekGonder(CAN0, 7, &g_gonderici_can_mesaj_objesi, 4);
ImSMOI15_MesafeAl(CAN0, 8, &g_alici_can_mesaj_objesi, 4);
g_s_smo15_3_verisi_geldi = 0;
}
}
}
my Interrupt handler
void CANIntHandler1(void)
{
unsigned long ul_durum;
ul_durum = CANIntStatus(CAN0_BASE, CAN_INT_STS_CAUSE);
if(ul_durum == CAN_INT_INTID_STATUS)
{
ul_durum = CANStatusGet(CAN0_BASE, CAN_STS_CONTROL);
g_bErrFlag = 1;
}
if(ul_durum == 1)
{
CANIntClear(CAN0_BASE, 1);
g_ulMsgCount++;
}
if(ul_durum == 3)
{
CANIntClear(CAN0_BASE, 3);
g_ulMsgCount++;
}
if(ul_durum == 5)
{
CANIntClear(CAN0_BASE, 5);
g_ulMsgCount++;
}
if(ul_durum == 7)
{
CANIntClear(CAN0_BASE, 7);
g_ulMsgCount++;
}
if(ul_durum == 2)
{
CANIntClear(CAN0_BASE, 2);
g_s_smo15_1_verisi_geldi = 1;
g_alici_can_mesaj_objesi = Im_CANMesajAl(CAN0, 2, &g_alici_can_mesaj_objesi);
Im_CANMesajObjesiIsle(&g_alici_can_mesaj_objesi, g_uc_gab_gelen_mesaj_bilgisi);
}
if(ul_durum == 4)
{
CANIntClear(CAN0_BASE, 4);
g_s_smo15_2_verisi_geldi = 1;
g_alici_can_mesaj_objesi = Im_CANMesajAl(CAN0, 4, &g_alici_can_mesaj_objesi);
Im_CANMesajObjesiIsle(&g_alici_can_mesaj_objesi, g_uc_gab_gelen_mesaj_bilgisi);
}
if(ul_durum == 6)
{
CANIntClear(CAN0_BASE, 6);
g_s_smo15_3_verisi_geldi = 1;
g_alici_can_mesaj_objesi = Im_CANMesajAl(CAN0, 6, &g_alici_can_mesaj_objesi);
Im_CANMesajObjesiIsle(&g_alici_can_mesaj_objesi, g_uc_gab_gelen_mesaj_bilgisi);
}
if(ul_durum == 8)
{
CANIntClear(CAN0_BASE, 8);
g_s_smo15_4_verisi_geldi = 1;
g_alici_can_mesaj_objesi = Im_CANMesajAl(CAN0, 8, &g_alici_can_mesaj_objesi);
Im_CANMesajObjesiIsle(&g_alici_can_mesaj_objesi, g_uc_gab_gelen_mesaj_bilgisi);
}
}
So, as seen in the code, I ve added 4 flags to know which message object had a receive interrupt, so i 'll handle the process. In the debug scene onyl the first flag seems 1, the others are 0. I don't understand why that happens.
What should I do? Any suggestion will be well received.
My best regards..