This time I need some help with the msCAN. The program runs in loop- mode, so the data from the transmiter buffer should turn up in the reveiver buffer. But this is not the case. Regards Sebastian #include <hidef.h> /* common defines and macros */ #include <6812dp256b.h> /* derivative information */ #include "my_vectors.h" static int cnt; static int mycnt; static struct daten { char IDR0; char IDR1; char IDR2; char IDR3; char DSR[8]; char DLR; char TBPR; char TSRH; char TSRL; }; void caninit(void) { CAN0CTL1_CANE=1; //msCAN-Enable CAN0CTL0_INITRQ=1; //CAN-Modul im Resetzustand //CANxTIDR0_IDE CAN0CTL1_CLKSRC=1; //Clock=Busclock CAN0IDMR0=0xFF; CAN0IDMR1=0xFF; CAN0IDMR2=0xFF; CAN0IDMR3=0xFF; CAN0IDMR4=0xFF; CAN0IDMR5=0xFF; CAN0IDMR6=0xFF; CAN0IDMR7=0xFF; CAN0CTL1=0xc7; //CAN0BTR0=0x01; //Bittiming nach Angabe des Notebooks //CAN0BTR1=0x1C; CAN0BTR0_SJW1=0; CAN0BTR0_SJW0=0; CAN0BTR0_BRP5=0; //Einstellung nur im INITRQ=1-Mod mlich CAN0BTR0_BRP4=0; CAN0BTR0_BRP3=0; CAN0BTR0_BRP2=0; CAN0BTR0_BRP1=1; CAN0BTR0_BRP0=1; CAN0BTR1_TSEG22=1; CAN0BTR1_TSEG21=1; CAN0BTR1_TSEG20=1; CAN0BTR1_TSEG12=0; CAN0BTR1_TSEG12=1; CAN0BTR1_TSEG11=0; CAN0BTR1_TSEG10=1; CAN0IDAC_IDAM1=1; //Filtereinstellung auf zwei 32 Acceptance Filter CAN0IDAC_IDAM0=1; CAN0CTL0_INITRQ=0; //Resetzustand aus MODE=0x80; //Enter Normal Single Chip Mode CAN0CTL0_WUPE=1; CAN0CTL1_LOOPB=1; //Loop Back Self Test Mode CAN0CTL0_TIME=1; //CAN-Timer enable DDRB=0xFF; PORTB=0; } void senddata(struct daten) { //Daten knen nur gesendet werden, wenn die TXEx-Flags 1 und damit die Sende-Puffer leer sind if(CAN0TFLG_TXE2==1) { //zum Puffern bereit CAN0TBSEL=0x04;//Puffer TX2 ist ausgwlt (durch einen Pointer) CAN0TXIDR0en.IDR0; /* MSCAN Identifier Register 0 */ CAN0TXIDR1en.IDR1; /* MSCAN Identifier Register 1 */ CAN0TXIDR2en.IDR2; /* MSCAN Identifier Register 2 */ CAN0TXIDR3en.IDR3; /* MSCAN Identifier Register 0 */ CAN0TXDSR0en.DSR[0]; /* MSCAN Data Segment Register 0 */ CAN0TXDSR1en.DSR[1]; /* MSCAN Data Segment Register 1 */ CAN0TXDSR2en.DSR[2]; /* MSCAN Data Segment Register 2 */ CAN0TXDSR3en.DSR[3]; /* MSCAN Data Segment Register 3 */ CAN0TXDSR4en.DSR[4]; /* MSCAN Data Segment Register 4 */ CAN0TXDSR5en.DSR[5]; /* MSCAN Data Segment Register 5 */ CAN0TXDSR6en.DSR[6]; /* MSCAN Data Segment Register 6 */ CAN0TXDSR7en.DSR[7]; /* MSCAN Data Segment Register 7 */ //CAN0RXERR; /* MSCAN Receive Error Counter Register */ CAN0TXDLR en.DLR; //Datenlgenregister CAN0TXTBPRen.TBPR; //Sendepufferpriorit CAN0TFLG_TXE2=1; //Lchen des Flag durch Einschreiben einer 1 f Sendebereitschaft } } void main(void) { /* put your own code here */ caninit(); struct daten message1 ={ 0,0,0,0, 55, 55, 55, 55, 55, 55, 55, 55, 16,0,0,0}; //DDRH=0; //PTH=0; //PERH=0xFF; senddata(message1); for(;;) { cnt++; //if(PTH==0x7F) //{ //} if(CAN0CTL0_SYNCH==1) { PORTB=0x55; } } } |
|
Problem with initialising msCAN 6812dp256b
Started by ●April 19, 2004
Reply by ●April 19, 20042004-04-19
Hello Sebastian, in my opinion, you have to set the CAN0IDAR0-Registers too! Otherwise the Controller drop the Message because it doesn't pass the Criteria! The Manual sys's: "On reception, each message is written into the background receive buffer. The CPU is only signalled to read the message if it passes the criteria in the identifier acceptance and identifier mask registers (accepted); otherwise, the message is overwritten by the next message (dropped)." Regards Christoph -----Ursprgliche Nachricht----- Von: Sebastian Schuster [mailto:] Gesendet: Montag, 19. April 2004 09:24 An: Betreff: [68HC12] Problem with initialising msCAN 6812dp256b This time I need some help with the msCAN. The program runs in loop- mode, so the data from the transmiter buffer should turn up in the reveiver buffer. But this is not the case. Regards Sebastian #include <hidef.h> /* common defines and macros */ #include <6812dp256b.h> /* derivative information */ #include "my_vectors.h" static int cnt; static int mycnt; static struct daten { char IDR0; char IDR1; char IDR2; char IDR3; char DSR[8]; char DLR; char TBPR; char TSRH; char TSRL; }; void caninit(void) { CAN0CTL1_CANE=1; //msCAN-Enable CAN0CTL0_INITRQ=1; //CAN-Modul im Resetzustand //CANxTIDR0_IDE CAN0CTL1_CLKSRC=1; //Clock=Busclock CAN0IDMR0=0xFF; CAN0IDMR1=0xFF; CAN0IDMR2=0xFF; CAN0IDMR3=0xFF; CAN0IDMR4=0xFF; CAN0IDMR5=0xFF; CAN0IDMR6=0xFF; CAN0IDMR7=0xFF; CAN0CTL1=0xc7; //CAN0BTR0=0x01; //Bittiming nach Angabe des Notebooks //CAN0BTR1=0x1C; CAN0BTR0_SJW1=0; CAN0BTR0_SJW0=0; CAN0BTR0_BRP5=0; //Einstellung nur im INITRQ=1-Mod mlich CAN0BTR0_BRP4=0; CAN0BTR0_BRP3=0; CAN0BTR0_BRP2=0; CAN0BTR0_BRP1=1; CAN0BTR0_BRP0=1; CAN0BTR1_TSEG22=1; CAN0BTR1_TSEG21=1; CAN0BTR1_TSEG20=1; CAN0BTR1_TSEG12=0; CAN0BTR1_TSEG12=1; CAN0BTR1_TSEG11=0; CAN0BTR1_TSEG10=1; CAN0IDAC_IDAM1=1; //Filtereinstellung auf zwei 32 Acceptance Filter CAN0IDAC_IDAM0=1; CAN0CTL0_INITRQ=0; //Resetzustand aus MODE=0x80; //Enter Normal Single Chip Mode CAN0CTL0_WUPE=1; CAN0CTL1_LOOPB=1; //Loop Back Self Test Mode CAN0CTL0_TIME=1; //CAN-Timer enable DDRB=0xFF; PORTB=0; } void senddata(struct daten) { //Daten knen nur gesendet werden, wenn die TXEx-Flags 1 und damit die Sende-Puffer leer sind if(CAN0TFLG_TXE2==1) { //zum Puffern bereit CAN0TBSEL=0x04;//Puffer TX2 ist ausgwlt (durch einen Pointer) CAN0TXIDR0en.IDR0; /* MSCAN Identifier Register 0 */ CAN0TXIDR1en.IDR1; /* MSCAN Identifier Register 1 */ CAN0TXIDR2en.IDR2; /* MSCAN Identifier Register 2 */ CAN0TXIDR3en.IDR3; /* MSCAN Identifier Register 0 */ CAN0TXDSR0en.DSR[0]; /* MSCAN Data Segment Register 0 */ CAN0TXDSR1en.DSR[1]; /* MSCAN Data Segment Register 1 */ CAN0TXDSR2en.DSR[2]; /* MSCAN Data Segment Register 2 */ CAN0TXDSR3en.DSR[3]; /* MSCAN Data Segment Register 3 */ CAN0TXDSR4en.DSR[4]; /* MSCAN Data Segment Register 4 */ CAN0TXDSR5en.DSR[5]; /* MSCAN Data Segment Register 5 */ CAN0TXDSR6en.DSR[6]; /* MSCAN Data Segment Register 6 */ CAN0TXDSR7en.DSR[7]; /* MSCAN Data Segment Register 7 */ //CAN0RXERR; /* MSCAN Receive Error Counter Register */ CAN0TXDLR en.DLR; //Datenlgenregister CAN0TXTBPRen.TBPR; //Sendepufferpriorit CAN0TFLG_TXE2=1; //Lchen des Flag durch Einschreiben einer 1 f Sendebereitschaft } } void main(void) { /* put your own code here */ caninit(); struct daten message1 ={ 0,0,0,0, 55, 55, 55, 55, 55, 55, 55, 55, 16,0,0,0}; //DDRH=0; //PTH=0; //PERH=0xFF; senddata(message1); for(;;) { cnt++; //if(PTH==0x7F) //{ //} if(CAN0CTL0_SYNCH==1) { PORTB=0x55; } } } --------------------To learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu o learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu Yahoo! Groups Links |
|
Reply by ●April 19, 20042004-04-19
But when setting CAN0IDAR [0...7] with 0xFF nothing really has changed. Because my mcu has no identifer-number, how will it be possible that my test-message could pass the identifer-filter? --- In , Christoph Brge <mistertom20@g...> wrote: > Hello Sebastian, > > in my opinion, you have to set the CAN0IDAR0-Registers too! > Otherwise the Controller drop the Message because it doesn't > pass the Criteria! > > The Manual sys's: > "On reception, each message is written into the background receive > buffer. The CPU is only signalled to read the message if it passes the > criteria in the identifier acceptance and identifier mask registers > (accepted); otherwise, the message is overwritten by the next message > (dropped)." > > Regards Christoph > > -----Ursprgliche Nachricht----- > Von: Sebastian Schuster [mailto:schusti@w...] > Gesendet: Montag, 19. April 2004 09:24 > An: > Betreff: [68HC12] Problem with initialising msCAN 6812dp256b > This time I need some help with the msCAN. The program runs in loop- > mode, so the data from the transmiter buffer should turn up in the > reveiver buffer. But this is not the case. > > Regards > > Sebastian > #include <hidef.h> /* common defines and macros > */ > #include <6812dp256b.h> /* derivative information */ > #include "my_vectors.h" > static int cnt; > static int mycnt; > > static struct daten > { > > char IDR0; > char IDR1; > char IDR2; > char IDR3; > char DSR[8]; > char DLR; > > char TBPR; > char TSRH; > char TSRL; > > }; > void caninit(void) > { > > CAN0CTL1_CANE=1; //msCAN-Enable > > CAN0CTL0_INITRQ=1; //CAN-Modul im Resetzustand > > //CANxTIDR0_IDE > CAN0CTL1_CLKSRC=1; //Clock=Busclock > > CAN0IDMR0=0xFF; > CAN0IDMR1=0xFF; > CAN0IDMR2=0xFF; > CAN0IDMR3=0xFF; > CAN0IDMR4=0xFF; > CAN0IDMR5=0xFF; > CAN0IDMR6=0xFF; > CAN0IDMR7=0xFF; > > CAN0CTL1=0xc7; > //CAN0BTR0=0x01; //Bittiming nach Angabe des > Notebooks > //CAN0BTR1=0x1C; > > CAN0BTR0_SJW1=0; > CAN0BTR0_SJW0=0; > > CAN0BTR0_BRP5=0; //Einstellung nur im INITRQ=1-Mod > mlich > CAN0BTR0_BRP4=0; > CAN0BTR0_BRP3=0; > CAN0BTR0_BRP2=0; > CAN0BTR0_BRP1=1; > CAN0BTR0_BRP0=1; > CAN0BTR1_TSEG22=1; > CAN0BTR1_TSEG21=1; > CAN0BTR1_TSEG20=1; > > CAN0BTR1_TSEG12=0; > CAN0BTR1_TSEG12=1; > CAN0BTR1_TSEG11=0; > CAN0BTR1_TSEG10=1; > CAN0IDAC_IDAM1=1; //Filtereinstellung auf zwei 32 > Acceptance Filter > CAN0IDAC_IDAM0=1; > CAN0CTL0_INITRQ=0; //Resetzustand aus > MODE=0x80; //Enter Normal Single Chip > Mode > > CAN0CTL0_WUPE=1; > CAN0CTL1_LOOPB=1; //Loop Back Self Test Mode > CAN0CTL0_TIME=1; //CAN-Timer enable > > DDRB=0xFF; > PORTB=0; > } > > void senddata(struct daten) > { > //Daten knen nur gesendet werden, wenn die TXEx-Flags 1 und > damit die Sende-Puffer leer sind > if(CAN0TFLG_TXE2==1) > { > //zum Puffern bereit > CAN0TBSEL=0x04;//Puffer TX2 ist ausgwlt (durch > einen Pointer) > > CAN0TXIDR0en.IDR0; /* MSCAN Identifier Register 0 > */ > CAN0TXIDR1en.IDR1; /* MSCAN Identifier Register 1 > */ > CAN0TXIDR2en.IDR2; /* MSCAN Identifier Register 2 > */ > CAN0TXIDR3en.IDR3; /* MSCAN Identifier Register 0 > */ > > CAN0TXDSR0en.DSR[0]; /* MSCAN Data Segment > Register 0 */ > CAN0TXDSR1en.DSR[1]; /* MSCAN Data Segment > Register 1 */ > CAN0TXDSR2en.DSR[2]; /* MSCAN Data Segment > Register 2 */ > CAN0TXDSR3en.DSR[3]; /* MSCAN Data Segment > Register 3 */ > CAN0TXDSR4en.DSR[4]; /* MSCAN Data Segment > Register 4 */ > CAN0TXDSR5en.DSR[5]; /* MSCAN Data Segment > Register 5 */ > CAN0TXDSR6en.DSR[6]; /* MSCAN Data Segment > Register 6 */ > CAN0TXDSR7en.DSR[7]; /* MSCAN Data Segment > Register 7 */ > //CAN0RXERR; /* MSCAN Receive Error Counter Register > */ > > CAN0TXDLR en.DLR; //Datenlgenregister > CAN0TXTBPRen.TBPR; //Sendepufferpriorit > CAN0TFLG_TXE2=1; //Lchen des Flag > durch Einschreiben einer 1 f Sendebereitschaft > } > } > > void main(void) { > /* put your own code here */ > caninit(); > struct daten message1 ={ 0,0,0,0, > 55, 55, 55, > 55, 55, 55, 55, 55, > 16,0,0,0}; > //DDRH=0; > //PTH=0; > //PERH=0xFF; > > senddata(message1); > for(;;) > { > cnt++; > > //if(PTH==0x7F) > //{ > > //} > > if(CAN0CTL0_SYNCH==1) > { > PORTB=0x55; > } > > } > } > > > --------------------To learn more about > Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > o learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > > Yahoo! Groups Links |
Reply by ●April 23, 20042004-04-23
Is filtering applied in loop back mode? I have written an msCAN program
in assembly for the D60A chip and seem to remember that the very first thing I experimented with was the loop back mode to talk to myself ( I do that a lot) and got the sending portion to work but I could not get the filtering to do anything. I then started the experiment with a receive program using loopback and ignoring filtering. Once both of these were working I started to work on the same two programs without loopback and set up filtering to accept all msgs. My problems were frustrating because of the bit timing so we bought a tinCAN interface and discovered www.port.de! It did not take long to straighten out the bus timiing problems after we got the tinCAN. I can tell you that I first tried to use 8 bit filters with the D60A chip and the filtering acted very strangely! After much frustration and getting and using the freebie filtering tool from metrowerks I learned a lot more and was even more convinced that the filtering of 8 bit filters was not working as it should - even Motorola could not see how to fix the filtering for 8 bit filters. So I went to standard 11 bit ID configured msgs and 16 bit filters and had very few problems. Sydney ----- Original Message ----- From: Sebastian Schuster To: Sent: Monday, April 19, 2004 8:28 AM Subject: [68HC12] Re: Problem with initialising msCAN 6812dp256b But when setting CAN0IDAR [0...7] with 0xFF nothing really has changed. Because my mcu has no identifer-number, how will it be possible that my test-message could pass the identifer-filter? --- In , Christoph Brge <mistertom20@g...> wrote: > Hello Sebastian, > > in my opinion, you have to set the CAN0IDAR0-Registers too! > Otherwise the Controller drop the Message because it doesn't > pass the Criteria! > > The Manual sys's: > "On reception, each message is written into the background receive > buffer. The CPU is only signalled to read the message if it passes the > criteria in the identifier acceptance and identifier mask registers > (accepted); otherwise, the message is overwritten by the next message > (dropped)." > > Regards Christoph > > -----Ursprgliche Nachricht----- > Von: Sebastian Schuster [mailto:schusti@w...] > Gesendet: Montag, 19. April 2004 09:24 > An: > Betreff: [68HC12] Problem with initialising msCAN 6812dp256b > This time I need some help with the msCAN. The program runs in loop- > mode, so the data from the transmiter buffer should turn up in the > reveiver buffer. But this is not the case. > > Regards > > Sebastian > #include <hidef.h> /* common defines and macros > */ > #include <6812dp256b.h> /* derivative information */ > #include "my_vectors.h" > static int cnt; > static int mycnt; > > static struct daten > { > > char IDR0; > char IDR1; > char IDR2; > char IDR3; > char DSR[8]; > char DLR; > > char TBPR; > char TSRH; > char TSRL; > > }; > void caninit(void) > { > > CAN0CTL1_CANE=1; //msCAN-Enable > > CAN0CTL0_INITRQ=1; //CAN-Modul im Resetzustand > > //CANxTIDR0_IDE > CAN0CTL1_CLKSRC=1; //Clock=Busclock > > CAN0IDMR0=0xFF; > CAN0IDMR1=0xFF; > CAN0IDMR2=0xFF; > CAN0IDMR3=0xFF; > CAN0IDMR4=0xFF; > CAN0IDMR5=0xFF; > CAN0IDMR6=0xFF; > CAN0IDMR7=0xFF; > > CAN0CTL1=0xc7; > //CAN0BTR0=0x01; //Bittiming nach Angabe des > Notebooks > //CAN0BTR1=0x1C; > > CAN0BTR0_SJW1=0; > CAN0BTR0_SJW0=0; > > CAN0BTR0_BRP5=0; //Einstellung nur im INITRQ=1-Mod > mlich > CAN0BTR0_BRP4=0; > CAN0BTR0_BRP3=0; > CAN0BTR0_BRP2=0; > CAN0BTR0_BRP1=1; > CAN0BTR0_BRP0=1; > CAN0BTR1_TSEG22=1; > CAN0BTR1_TSEG21=1; > CAN0BTR1_TSEG20=1; > > CAN0BTR1_TSEG12=0; > CAN0BTR1_TSEG12=1; > CAN0BTR1_TSEG11=0; > CAN0BTR1_TSEG10=1; > CAN0IDAC_IDAM1=1; //Filtereinstellung auf zwei 32 > Acceptance Filter > CAN0IDAC_IDAM0=1; > CAN0CTL0_INITRQ=0; //Resetzustand aus > MODE=0x80; //Enter Normal Single Chip > Mode > > CAN0CTL0_WUPE=1; > CAN0CTL1_LOOPB=1; //Loop Back Self Test Mode > CAN0CTL0_TIME=1; //CAN-Timer enable > > DDRB=0xFF; > PORTB=0; > } > > void senddata(struct daten) > { > //Daten knen nur gesendet werden, wenn die TXEx-Flags 1 und > damit die Sende-Puffer leer sind > if(CAN0TFLG_TXE2==1) > { > //zum Puffern bereit > CAN0TBSEL=0x04;//Puffer TX2 ist ausgwlt (durch > einen Pointer) > > CAN0TXIDR0en.IDR0; /* MSCAN Identifier Register 0 > */ > CAN0TXIDR1en.IDR1; /* MSCAN Identifier Register 1 > */ > CAN0TXIDR2en.IDR2; /* MSCAN Identifier Register 2 > */ > CAN0TXIDR3en.IDR3; /* MSCAN Identifier Register 0 > */ > > CAN0TXDSR0en.DSR[0]; /* MSCAN Data Segment > Register 0 */ > CAN0TXDSR1en.DSR[1]; /* MSCAN Data Segment > Register 1 */ > CAN0TXDSR2en.DSR[2]; /* MSCAN Data Segment > Register 2 */ > CAN0TXDSR3en.DSR[3]; /* MSCAN Data Segment > Register 3 */ > CAN0TXDSR4en.DSR[4]; /* MSCAN Data Segment > Register 4 */ > CAN0TXDSR5en.DSR[5]; /* MSCAN Data Segment > Register 5 */ > CAN0TXDSR6en.DSR[6]; /* MSCAN Data Segment > Register 6 */ > CAN0TXDSR7en.DSR[7]; /* MSCAN Data Segment > Register 7 */ > //CAN0RXERR; /* MSCAN Receive Error Counter Register > */ > > CAN0TXDLR en.DLR; //Datenlgenregister > CAN0TXTBPRen.TBPR; //Sendepufferpriorit > CAN0TFLG_TXE2=1; //Lchen des Flag > durch Einschreiben einer 1 f Sendebereitschaft > } > } > > void main(void) { > /* put your own code here */ > caninit(); > struct daten message1 ={ 0,0,0,0, > 55, 55, 55, > 55, 55, 55, 55, 55, > 16,0,0,0}; > //DDRH=0; > //PTH=0; > //PERH=0xFF; > > senddata(message1); > for(;;) > { > cnt++; > > //if(PTH==0x7F) > //{ > > //} > > if(CAN0CTL0_SYNCH==1) > { > PORTB=0x55; > } > > } > } > > > --------------------To learn more about > Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > o learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > > Yahoo! Groups Links --------------------To learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu o learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu ---- -- Yahoo! Groups Links a.. To |
Reply by ●April 23, 20042004-04-23
Have you tried to send a msg frame and look for it in memory with the debugger? In my unit, the D60A, I look at $0940 because of the offset of $0800 for relocated registers. We had a lot of problems with the dp256 so we changed to the d60A, but they both use msCAN! Motorola has several ANs that you should check out. And, as I said before, in loopback mode, timing and filtering should not be a problem, just keep looking for the CAN msg frame in the receive buffer register to prove your sending routine is OK. Sydney ----- Original Message ----- From: Christoph Brge To: Sent: Monday, April 19, 2004 4:27 AM Subject: AW: [68HC12] Problem with initialising msCAN 6812dp256b Hello Sebastian, in my opinion, you have to set the CAN0IDAR0-Registers too! Otherwise the Controller drop the Message because it doesn't pass the Criteria! The Manual sys's: "On reception, each message is written into the background receive buffer. The CPU is only signalled to read the message if it passes the criteria in the identifier acceptance and identifier mask registers (accepted); otherwise, the message is overwritten by the next message (dropped)." Regards Christoph -----Ursprgliche Nachricht----- Von: Sebastian Schuster [mailto:] Gesendet: Montag, 19. April 2004 09:24 An: Betreff: [68HC12] Problem with initialising msCAN 6812dp256b This time I need some help with the msCAN. The program runs in loop- mode, so the data from the transmiter buffer should turn up in the reveiver buffer. But this is not the case. Regards Sebastian #include <hidef.h> /* common defines and macros */ #include <6812dp256b.h> /* derivative information */ #include "my_vectors.h" static int cnt; static int mycnt; static struct daten { char IDR0; char IDR1; char IDR2; char IDR3; char DSR[8]; char DLR; char TBPR; char TSRH; char TSRL; }; void caninit(void) { CAN0CTL1_CANE=1; //msCAN-Enable CAN0CTL0_INITRQ=1; //CAN-Modul im Resetzustand //CANxTIDR0_IDE CAN0CTL1_CLKSRC=1; //Clock=Busclock CAN0IDMR0=0xFF; CAN0IDMR1=0xFF; CAN0IDMR2=0xFF; CAN0IDMR3=0xFF; CAN0IDMR4=0xFF; CAN0IDMR5=0xFF; CAN0IDMR6=0xFF; CAN0IDMR7=0xFF; CAN0CTL1=0xc7; //CAN0BTR0=0x01; //Bittiming nach Angabe des Notebooks //CAN0BTR1=0x1C; CAN0BTR0_SJW1=0; CAN0BTR0_SJW0=0; CAN0BTR0_BRP5=0; //Einstellung nur im INITRQ=1-Mod mlich CAN0BTR0_BRP4=0; CAN0BTR0_BRP3=0; CAN0BTR0_BRP2=0; CAN0BTR0_BRP1=1; CAN0BTR0_BRP0=1; CAN0BTR1_TSEG22=1; CAN0BTR1_TSEG21=1; CAN0BTR1_TSEG20=1; CAN0BTR1_TSEG12=0; CAN0BTR1_TSEG12=1; CAN0BTR1_TSEG11=0; CAN0BTR1_TSEG10=1; CAN0IDAC_IDAM1=1; //Filtereinstellung auf zwei 32 Acceptance Filter CAN0IDAC_IDAM0=1; CAN0CTL0_INITRQ=0; //Resetzustand aus MODE=0x80; //Enter Normal Single Chip Mode CAN0CTL0_WUPE=1; CAN0CTL1_LOOPB=1; //Loop Back Self Test Mode CAN0CTL0_TIME=1; //CAN-Timer enable DDRB=0xFF; PORTB=0; } void senddata(struct daten) { //Daten knen nur gesendet werden, wenn die TXEx-Flags 1 und damit die Sende-Puffer leer sind if(CAN0TFLG_TXE2==1) { //zum Puffern bereit CAN0TBSEL=0x04;//Puffer TX2 ist ausgwlt (durch einen Pointer) CAN0TXIDR0en.IDR0; /* MSCAN Identifier Register 0 */ CAN0TXIDR1en.IDR1; /* MSCAN Identifier Register 1 */ CAN0TXIDR2en.IDR2; /* MSCAN Identifier Register 2 */ CAN0TXIDR3en.IDR3; /* MSCAN Identifier Register 0 */ CAN0TXDSR0en.DSR[0]; /* MSCAN Data Segment Register 0 */ CAN0TXDSR1en.DSR[1]; /* MSCAN Data Segment Register 1 */ CAN0TXDSR2en.DSR[2]; /* MSCAN Data Segment Register 2 */ CAN0TXDSR3en.DSR[3]; /* MSCAN Data Segment Register 3 */ CAN0TXDSR4en.DSR[4]; /* MSCAN Data Segment Register 4 */ CAN0TXDSR5en.DSR[5]; /* MSCAN Data Segment Register 5 */ CAN0TXDSR6en.DSR[6]; /* MSCAN Data Segment Register 6 */ CAN0TXDSR7en.DSR[7]; /* MSCAN Data Segment Register 7 */ //CAN0RXERR; /* MSCAN Receive Error Counter Register */ CAN0TXDLR en.DLR; //Datenlgenregister CAN0TXTBPRen.TBPR; //Sendepufferpriorit CAN0TFLG_TXE2=1; //Lchen des Flag durch Einschreiben einer 1 f Sendebereitschaft } } void main(void) { /* put your own code here */ caninit(); struct daten message1 ={ 0,0,0,0, 55, 55, 55, 55, 55, 55, 55, 55, 16,0,0,0}; //DDRH=0; //PTH=0; //PERH=0xFF; senddata(message1); for(;;) { cnt++; //if(PTH==0x7F) //{ //} if(CAN0CTL0_SYNCH==1) { PORTB=0x55; } } } --------------------To learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu o learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu Yahoo! Groups Links --------------------To learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu o learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu ---- -- Yahoo! Groups Links a.. To |