#include<lpc21xx.h>
unsigned int val,n,fs,id,data;
unsigned char i=0;
void CAN_init()
{
unsigned int * pAddr;
pAddr = (unsigned int * )0xE0038000;
//DWORD *pAddr;
PINSEL1 |=0x00040000;
C1MOD = 0x01;
C1GSR = 0x00;
C1IER = 0x02;
C1BTR = 0x001C001D;
C1EWL = 0xff;
C1MOD = 0x00;
//pAddr = (DWORD *) AFRAM;
AFMR = 0x00000001;
SFF_sa = 0;
*pAddr = 0x211f20cf;
pAddr++;
*pAddr = 0x206B2064;
SFF_GRP_sa = 0x00000008;
EFF_sa = 0x00000008;
EFF_GRP_sa = 0x00000008;
ENDofTable = 0x00000008;
AFMR = 0x00000000;
}
void MSdelay(unsigned int rtime)
{
unsigned int r,s;
for(r=0;r<rtime;r++)
for(s=0;s<7500;s++);
}
int main()
{
unsigned int i='a';
//unsigned int status;
CAN_init();
PINSEL0=0;
IO0DIR= 0x000000ff;
while(1)
{
while((C1SR & 0x00000004) != 0x00000004);
C1TFI1 = 0x00040000;
C1TID1 = 0x000000CF;
C1TDA1 = i;
C1CMR = 0x21;
//val=C1ICR;
//while((C1GSR & 0x00000008) != 0x00000008);
//status = C1GSR;
while((C1GSR & 0x00000008) != 0x00000008);
//{
//status = C1GSR;
//}
IO0SET = 0x000000ff;
MSdelay (1000);
IO0CLR = 0x000000ff;
MSdelay(1000);
}
}