This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems with the CAN (C515C)!!!

My problem:
My program is able to send messages but not to save the incoming messages.
The following program shoud be able to save the incoming telegrams and then send
the new information out.
Is somebody able to help me.
Maybe its an initialization problem.
Here are the source code without the headers:

#pragma small

#include <regc515c.h>
#include <c515can.h>
#include<absacc.h> 

void lesen (void);
void Empfang (void);
void iniint(void);
void inican(void);
void ini_ACC1(void);

unsigned char empf[8];


void iniint(void)
{
                  
                   
                  
 TMOD=0x11;       /* 16 bit timer*/
 TR0=0;           /*timer0 off*/
 TH0=0xBB;        /*timer 0 load with 10 ms */
 TL0=0x00;
 TF0=0;           /*timerflag clear*/
 TR0=1;           /*timer0 on*/

 EAL=1;          /*enable interrupt*/
 ET0=1;          /*interrupt for Timer0 on*/
}

void inican(void)
{
 SYSCON = 0x20; // XMAP0 und XMAP1, on extern
 CR = 0xfc;
 GMS0 = 0xFF;    // mask off
 GMS1 = 0xFF;
 UGML0 = 0xFF;
 UGML1 = 0xFF;
 LGML0 = 0xFF;
 LGML1 = 0xFF;
 UMLM0 = 0xFF;
 UMLM1 = 0xFF;
 LMLM0 = 0xFF;
 LMLM1 = 0xFF;

 CR = 0x41;     // start initialization -> INIT=1, CCE=1

 BTR0 = 0xC0;
 BTR1 = 0x6B;    // from ApNote 0820

 SR = 0xE7;  // TXOK and RXOK clear
 CR = 0x00;  // CCE=0 -> Baudrate off

 MCR0_1=0x55;                     // messages off
 MCR0_2=0x55;                     
 MCR0_3=0x55;                     
 MCR0_4=0x55;                     
 MCR0_5=0x55;                     
 MCR0_6=0x55;                     
 MCR0_7=0x55;                     
 MCR0_8=0x55;                     
 MCR0_9=0x55;                     
 MCR0_A=0x55;                     
 MCR0_B=0x55;                     
 MCR0_C=0x55;                
 MCR0_D=0x55;                     
 MCR0_E=0x55;                     
 MCR0_F=0x55;   
 SYSCON = 0x21; // XMAP0, extern off
}

//**************************************************************************************

void ini_ACC1(void)
{
 SYSCON = 0x20; 
 MCR1_5 = 0xFB; 				/*CPUUPD=1*/
 UAR0_5 = 0x3A; UAR1_5 = 0x00;		/*identifier 0x1D0*/
 MCFG_5 =0x88; 				/*data length, transmission */
 DB0_5 = 0x00;    			
 DB1_5 = 0x00;    			
 DB2_5 = 0x00;    			
 DB3_5 = 0x00;    			
 DB4_5 = 0x00;    			
 DB5_5 = 0x00;    			
 DB6_5 = 0x00;    			
 DB7_5 = 0x00;    			
 MCR0_5 = 0xA5; 				/*MSGVAL=1, TXIE=1, RXIE=0???, INPND=0;*/
 MCR1_5 = 0x55;				/*RMTPNP=0, TXRQ=0, CPUUPD=0, NEWDAT=0*/
 SYSCON = 0x21; 
}

//**************************************************************************************

void Empfang (void)  // telegram incoming message
{
 SYSCON = 0x20;                          
 MCR1_6 = 0xFB; 			/*MSGLST/CPUUPD=1*/
 UAR0_6 = 0xa4; UAR1_6 = 0x60;		/*identifier 0x523h*/
 MCFG_6 = 0x80; 				/*datalength incoming message*/
 MCR0_6 = 0xA9; 				/*MSGVAL=1, TXIE=1, RXIE=1,INPND=0;*/
 MCR1_6 = 0x55;			/*RMTPNP=0, TXRQ=0, CPUUPD=0, NEWDAT=0*/
 SYSCON = 0x21;
}

//******************************read

void lesen (void)       //read incoming message
{
 SYSCON = 0x21; 
 empf[0] = DB0_6;
 empf[1] = DB1_6;
 empf[2] = DB2_6;
 empf[3] = DB3_6;
 empf[4] = DB4_6;
 empf[5] = DB5_6;
 empf[6] = DB6_6;
 empf[7] = DB7_6;
 SYSCON = 0x20;
}
//**************************zyklisch()********************************

void zyklisch (void) interrupt 1                                        
{
 static unsigned char x;
   
 TR0=0;                          /*Timer0 off*/
 TH0=0xBB;                       /*Timer0 = 10ms */
 TL0=0x00;
 TF0=0;                          /*Timerflag 0 clear*/
 TR0=1;                          /*Timer0 start*/
 x++;                    

if(x==2)                
   {
    x=0;                  
    lesen();
    SYSCON = 0x20;
    DB0_5 = empf[0];
    DB1_5 = empf[1];
    DB2_5 = empf[2];
    DB3_5 = empf[3];
    DB4_5 = empf[4];
    DB5_5 = empf[5];
    DB6_5 = empf[6];
    DB7_5 = empf[7];
    MCR1_5 = 0xEF;               /*Send ACC1 to CAN-BUS*/ 
    SYSCON = 0x21;
   }
}

//******************************************

void main (void)

{
 Empfang ();
 iniint();
 inican();
 ini_ACC1();
 while(1);
}