Заранее спасибо.
Код
#include <LPC21xx.H>
//LED on/off functions ***************/
void GREEN_ON(void)
{
IOCLR0=0x00002000;
}
void GREEN_OFF(void)
{
IOSET0=0x00002000;
}
void CAN2IRQ (void) __attribute__ ((interrupt("IRQ"))); //Declare the RX IRQ
//unsigned *FilterPtr;
int main(void)
{
IODIR1 = 0x00FF0000; //PORT1 all pins OUT
IODIR0 = 0xffffffff; //PORT0 all pins OUT
IOSET0=0xFFFFFFFF; //PORT0 all pins in 1
VPBDIV = 0x00000001; //Set PClk to 60Mhz
IODIR1 = 0x00FF0000; // set all ports to output
PINSEL1 |= 0x00014000; //Enable Pin 0.25 as CAN1 RX
C2MOD = 0x00000001; //Set CAN controller into reset
C2BTR = 0x006B001D; //100 //Set bit timing to 125k
C2IER = 0x00000001; //Enable the Receive interrupt
VICVectCntl0 = 0x0000003A; //select a priority slot for a given interrupt
VICVectAddr0 = (unsigned)CAN2IRQ; //pass the address of the IRQ into the VIC slot
VICIntEnable = 0x04000000; //enable interrupt
AFMR = 0x00000001; //Disable the Acceptance filters to allow setup of the table
/*Fi/*lterPtr = (unsigned)0xE0038000; //Set pointer to start of acceptance filter menory
*FilterPtr = 0x20012002; //Write values to the Standard acceptance filter table
FilterPtr++; //Increment pointer by four bytes
*FilterPtr = 0x20032004; //Write next two filter values
SFF_sa = 0x00000000; //Set start address of Standard table
SFF_GRP_sa = 0x00000008; //Set start address of Standard group table
EFF_sa = 0x00000008; //Set start address of Extended table
EFF_GRP_sa = 0x00000008; //Set start address of Extended group table
ENDofTable = 0x00000008; //Set end of table address
AFMR = 0x00000000; */ //Enable Acceptance filters
C2MOD = 0x00000000; //Release CAN controller
IOCLR1 = 0xffffffff; //clear output pins
while(1)
{
;//waiting interrupt
}
}
void CAN2IRQ (void)
{
GREEN_OFF(); //set output pins
C1CMR = 0x00000004; //release the recieve buffer
VICVectAddr = 0x00000000; //Signal the end of interrupt
while(1){};
}
//LED on/off functions ***************/
void GREEN_ON(void)
{
IOCLR0=0x00002000;
}
void GREEN_OFF(void)
{
IOSET0=0x00002000;
}
void CAN2IRQ (void) __attribute__ ((interrupt("IRQ"))); //Declare the RX IRQ
//unsigned *FilterPtr;
int main(void)
{
IODIR1 = 0x00FF0000; //PORT1 all pins OUT
IODIR0 = 0xffffffff; //PORT0 all pins OUT
IOSET0=0xFFFFFFFF; //PORT0 all pins in 1
VPBDIV = 0x00000001; //Set PClk to 60Mhz
IODIR1 = 0x00FF0000; // set all ports to output
PINSEL1 |= 0x00014000; //Enable Pin 0.25 as CAN1 RX
C2MOD = 0x00000001; //Set CAN controller into reset
C2BTR = 0x006B001D; //100 //Set bit timing to 125k
C2IER = 0x00000001; //Enable the Receive interrupt
VICVectCntl0 = 0x0000003A; //select a priority slot for a given interrupt
VICVectAddr0 = (unsigned)CAN2IRQ; //pass the address of the IRQ into the VIC slot
VICIntEnable = 0x04000000; //enable interrupt
AFMR = 0x00000001; //Disable the Acceptance filters to allow setup of the table
/*Fi/*lterPtr = (unsigned)0xE0038000; //Set pointer to start of acceptance filter menory
*FilterPtr = 0x20012002; //Write values to the Standard acceptance filter table
FilterPtr++; //Increment pointer by four bytes
*FilterPtr = 0x20032004; //Write next two filter values
SFF_sa = 0x00000000; //Set start address of Standard table
SFF_GRP_sa = 0x00000008; //Set start address of Standard group table
EFF_sa = 0x00000008; //Set start address of Extended table
EFF_GRP_sa = 0x00000008; //Set start address of Extended group table
ENDofTable = 0x00000008; //Set end of table address
AFMR = 0x00000000; */ //Enable Acceptance filters
C2MOD = 0x00000000; //Release CAN controller
IOCLR1 = 0xffffffff; //clear output pins
while(1)
{
;//waiting interrupt
}
}
void CAN2IRQ (void)
{
GREEN_OFF(); //set output pins
C1CMR = 0x00000004; //release the recieve buffer
VICVectAddr = 0x00000000; //Signal the end of interrupt
while(1){};
}