jjeevan007
Full Member level 5
hi to all,
i am implementing can protocol using two LPC2129 controller
one is sending data and one is receiving data....
here is code for sending
here is code for receiving
in simulating i can able see sending of data correctly,
but i am not able simulate the receiving part so help me with receiving part of my code
regards
jeevan
i am implementing can protocol using two LPC2129 controller
one is sending data and one is receiving data....
here is code for sending
Code:
#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);
}
}
here is code for receiving
Code:
#include<lpc21xx.h>
unsigned int val,n;
void CAN_init()
{
unsigned int * pAddr;
pAddr = (unsigned int * )0xE0038000;
PINSEL1 |=0x00040000;
C1MOD = 0x01;
C1GSR = 0x00;
C1IER = 0x00;
C1BTR = 0x001C001D;
C1EWL = 0xff;
C1MOD = 0x00;
AFMR = 0x00000001;
*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++);
}
void lcdcommand(void)
{
MSdelay(6);
IODIR1=0X00FF0000; /* P1.16..23 defined as Outputs */
IOPIN1 = n;
IOCLR0=0x00000010; /* RS(P0.4)=0 */
IOCLR0=0x00000020; /* R/W(P0.5)=0 */
IOSET0=0x00000040; /* EN(P0.6)=1 */
IOCLR0=0x00000040; /* EN(P0.6)=0 */
}
void lcddatawrt(void)
{
MSdelay(4);
IODIR1=0X00FF0000; /* P1.16..23 defined as Outputs */
IOPIN1 = n;
IOSET0=0x00000010; /* RS(P0.4)=1 */
IOCLR0=0x00000020; /* R/W(P0.5)=0 */
IOSET0=0x00000040; /* EN(P0.6)=1 */
IOCLR0=0x00000040; /* EN(P0.6)=0 */
}
void lcd_initialization(void)
{
//PINSEL1=0x00000000; /*MAKE 0.28,0.29,0.30 AS I/O*/
//PINSEL2=0x00000000; /*MAKE 1.16...1.23 AS I/O*/
n=0x00380000;
lcdcommand();
n=0x000c0000;
lcdcommand();
n=0x00060000;
lcdcommand();
n=0x00010000;
lcdcommand();
}
int main()
{
//unsigned int temp;
PINSEL0=0;
IO0DIR= 0x000000ff;
lcd_initialization();
CAN_init();
n=0x00310000;
lcddatawrt();
while(1)
{
n=0x00310000;
lcddatawrt();
while ((C1GSR & 0x00000001) !=0x00000001)
{
IO0SET = 0x0000000f;
//MSdelay (2000);
//IO0CLR = 0x0000000f;
//MSdelay(2000);
}
IO0CLR = 0X0000000F;
//n=0x00310000;
//lcddatawrt();
//temp=C1RFS;
if((C1RFS & 0x40000000)!=0x40000000)
{
n=0x00310000;
lcddatawrt();
//if((temp & 0x80000000) == 0x80000000)
if (C1RID == 0x000000CF)
{
val = C1RDA;
n=val<<16;
lcddatawrt();
}
else;
C1CMR = 0x00000004;
}
}
/*
while((C1SR & 0x00000004) != 0x00000004);
C1TFI1 = 0x00040000;
C1TID1 = 0x000000CF;
C1TDA1 = i;
C1CMR = 0x21;
while((C1GSR & 0x00000008) != 0x00000008);
*/
//while(1);
}
in simulating i can able see sending of data correctly,
but i am not able simulate the receiving part so help me with receiving part of my code
regards
jeevan
Last edited: