Hallo miteinander, ich versuche gerade eine Kommunikation zwischen 2 identischen Controller (C515c) zu programmieren. Mein einer Controller sendet mir kontinuierlich ein Byte. Auf der Empfangsseite habe ich folgenden Code: #include "regc515c.h" #include "intc515c.h" #include "canreg.h" #include <stdio.h> void can_init (void); void send_1 (void); void def_1 (void); void main(void) { can_init(); EAL=1; def_1(); while(1) { } } unsigned char IE = 1; // all CAN interrupts enabled unsigned char SIE = 0; // status interrupts disabled unsigned char EIE = 0; // error interrupts disabled void can_init (void) { SYSCON &= 0xFC; // XMAP0=0, XMAP1=0 XPAGE = 0xF7; // CAN memory space in XRAM GMS0 = 0x20; GMS1 = 0x11; // global mask short UGML0 = 0x20; UGML1 = 0x11; // global mask long LGML0 = 0xFF; LGML1 = 0xFF; UMLM0 = 0xFF; UMLM1 = 0xFF; // last message mask LMLM0 = 0xFF; LMLM1 = 0xFF; CR = 0x41; // INIT=1 and CCE=1 (enable access baudrate) BTR0 = 0xC1; BTR1 = 0x6B; // access bit timing registers: 10 MHz,250 kBaud CR = 0x01; // CCE=0 (disable access baudrate) SR = 0xE7; // clear TXOK and RXOK MCR0_M1 = 0x55; // message 1 not valid MCR0_M15 = 0x55; // message 15 not valid IEN2 = 2; // enable CAN interrupt (ECAN=1) CR = 0; // INIT=0 if ( IE) CR |= 0x02; // enable global can_int if (SIE) CR |= 0x04; // enable can_status_int if (EIE) CR |= 0x08; // enable can_error_int } //.............................................................. // definition message 1, standard transmission frame void def_1 (void) { MCR1_M1 = 0xFB; // CPUUPD=1 UAR0_M1 = 0x11; UAR1_M1 = 0x20;// identifier 00010001 001 MCFG_M1 = 0x10; // frame definition MCR0_M1 = 0x99; // MSGVAL=1, TXIE=0, RXIE=1, INTPND=0 MCR1_M1 = 0x55; // RMTPND=0, TXRQ=0, CPUUPD=0, NEWDAT=0 } //.............................................................. // CAN interrupt void int_can (void) interrupt CANI { unsigned char status, intreg; while (intreg = IR) {status = SR; SR = 0; // read and reset CAN status switch (intreg) {case 1: // status and error interrupt if (SIE) // status interrupts {if (status & 0x08) {}// transmit interrupt if (status & 0x10) {}// receive interrupt if (status & 0x07) {}// erroneous transfer } if (EIE) // error interrupts {if (status & 0x40) {}// EWRN has changed if (status & 0x80) {}// BUSOFF has changed } break; case 3: // message 1 interrupt MCR0_M1 = 0xFD; // reset INTPND if (status & 0x08) {} // transmit interrupt if (status & 0x10) {} // receive interrupt break; case 4: // message 2 interrupt MCR0_M1 = 0xFD; // reset INTPND if (status & 0x08) {}// transmit interrupt if (status & 0x10) { P5=DB0_M1; }// receive interrupt break; } } } Nun habe ich folgendes Problem. Wenn der Controller in die IR springt, bekomme ich als Status im SR ein ReceiveOK. Soweit so gut. Aber irgendwie bekomme ich im intreg(IR) ein Interrupt bei Message2 und nicht bei Message1. An was kann das liegen? mfG nic
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.