Last active
May 26, 2016 13:10
-
-
Save nnarain/236bbecdd56d976ca15a4b9df27dc339 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <hidef.h> /* common defines and macros */ | |
#include "derivative.h" /* derivative-specific definitions */ | |
#include "can.h" | |
void canInit(void); | |
void main(void) | |
{ | |
unsigned char errorflag; | |
unsigned char txbuff[] = "abcd"; | |
canInit(); | |
// wait while MSCAN is not syncd with the bus | |
while(!mscanIsSync()); | |
mscanEnable(); | |
EnableInterrupts; | |
for (;;) | |
{ | |
errorflag = mscanWrite(0x100, 0x00, txbuff, sizeof(txbuff)-1); | |
} | |
} | |
interrupt 38 void canRxHandler(void) | |
{ | |
unsigned char length, index; | |
unsigned char rxdata[8]; | |
length = mscanRxLength(); | |
mscanRead(rxdata, length); | |
} | |
void canInit() | |
{ | |
MsCanInitType init; | |
init.id = 0x100; | |
init.sjw = 4; | |
init.prescaler = 8; | |
init.tseg1 = 5; | |
init.tseg2 = 2; | |
init.options = CANCTL1_LOOPB_MASK; | |
mscanInitMode(); | |
mscanInit(&init); | |
mscanNormalMode(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment