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

ACCESS DALLAS DS80C400 CAN SRAM

Hello
I'm trying to initialize the CAN controller on the DS80C400 but I cant set the bit SWINT (C0C.0) to 0 (so the CAN controller never starts up). I wrote some valid values to C0BT1 (TSEG1 and TSEG2 other than zero). C0BT1 is locatet at the CAN data memory (and if the values TSEG1 and/or TSEG2 are zero --> SWINT will never go to 0). Now I suppose that I write the wrong memory location (access problem ? I use FVAR to acces the CAN data mem).

Here's the c-code from my initCAN routine:

void initCAN()
{
	printf("DEBUG_0: C0C: %bx \r\n", C0C);
	printf("DEBUG_1: C0S: %bx \r\n", C0S);
	while((C0C&0x08)==0x08)	//while CRST == 1 (I don't know why, but if I dont do this (just try one time)--> CRST wont go to 0
	{
		TA = 0xAA;	//get write access to protected bits..
		TA = 0x55;	//..got acces for 3 machine cycles
		C0C = 0x01;	//set software initialisation bit (SWINT = 1 --> disable CAN Controller)
	}
	printf("DEBUG_3: C0C: %bx \r\n", C0C);

	P5CNT |= 0x08;		//P5CNT.3 =1; enable CAN0 pins 5.0 / 5.1

	printf("DEBUG_5: C0C: %bx \r\n", C0C);

//baudrate TSEG ...
	//set C0BT0 = 0x42;
	FVAR(unsigned char, 0xFFDB04) = 0x42;	//SJW1-0 = 1; BPR5-0 = 0x02
	printf("DEBUG_6: C0BT0: %bx \r\n", FVAR(unsigned char, 0xFFDB04));
	printf("DEBUG_7: C0BT0_adr: %lx \r\n", &FVAR(unsigned char, 0xFFDB04));	// not shure if this works..

	COR &= 0xE7;	//C0BPR7-6 = 0; (Prescaler C0BPR0-7 is set to 2)

	//set C0BT0 = 0x56;
	FVAR(unsigned char, 0xFFDB05) = 0x56;	//TSEG1 = 6, TSEG2 =5, SMP = 0 -->0x56
	printf("DEBUG_8: C0BT1: %bx \r\n", FVAR(unsigned char, 0xFFDB05));
	printf("DEBUG_9: C0BT1_adr: %lx \r\n", &FVAR(unsigned char, 0xFFDB05));	// not shure if this works..
	//DBYTE[0xFFDB00+4] = 0x42;	//reg C0BT0: BR Prescaler = 2; SJW1-0 = 1;

	printf("DEBUG_10: C0C: %bx \r\n", C0C);

//enable message center 1
	//register C0M1AR0 - C0M1AR3
	FVAR(unsigned char, 0xFFDB12) = 0x00;	//Extended ID = 0..
	FVAR(unsigned char, 0xFFDB13) = 0x00;	//..
	FVAR(unsigned char, 0xFFDB14) = 0x00;	//..
	FVAR(unsigned char, 0xFFDB15) = 0x00;	//.. + WTOE = 0; (no overwrite enable on recieve)

	//register C0M1F
	FVAR(unsigned char, 0xFFDB16) = 0x88;	// 8 databytes, transmit, 11bit id, no message identification mask (recv.),
 											// no media identification mask
//enable interrups
	EA = 1;
	C0IE = 1;
	C0M1C = 0xC1;	//message center 1 ready, enable transmit interrupt


	TA = 0xAA;	//get write access to protected bits..
	TA = 0x55;	//..got acces for 3 machine cycles
	C0C = 0x00;	//clear software initialisation bit (SWINT = 0 --> enable CAN Controller)

	printf("DEBUG_11: C0C: %bx \r\n", C0C);
}

An here's the output:

DEBUG_0: C0C: 9

DEBUG_1: C0S: 0

DEBUG_3: C0C: 1

DEBUG_5: C0C: 1

DEBUG_6: C0BT0: 42

DEBUG_7: C0BT0_adr: db0400

DEBUG_8: C0BT1: 56

DEBUG_9: C0BT1_adr: db0500

DEBUG_10: C0C: 1

DEBUG_11: C0C: 1


As one can see, C0C never goes to 0x00 that means SWINT bit remains set and the CAN controller wont ever start up...

Anyone got an idea?? I've been trying for 3 days now... no solution.

Thanks in advance


some additional info:

- Im using STARTUP400.a51
- CAN data mem is (should be) at FFDBxx (because MCON register is 0xBF --> CMA bit is 1)
- C51 v7.07, AX51 v2.11 , LS51 v3.60
SOME TARGET OPTIONS:
- Mem Model: Large: variables in XDATA
- Code Rom Size: Contignuous mode
- OS: None
- box "far tyme memory support" checked
- Off-chip Xdata memory:
Ram at 0x10000 (size 0x3FFF)
Ram at 0xFFDB00 (size 0x100) CAN DATA.Is this OK??? I'm not shure!!!

Parents
  • Hi
    you didn't actually manage to set CMA=1.

    CMA was 1 all the time, I verified this in the startup code and with the debugger...

    But anyway, I've got the CAN-controller running now. While debugging, I noticed that r/w from/to absolute addresses above 0x7FFFFF doesn't work. So I did set CMA to 0 (CAN mem now @ 0x00DBxx) and access the mem like this:

    unsigned char far *can;
    ...
    //set C0BT0 = 0x42;
    can = &FVAR(unsigned char, 0x00DB04);
    *can = 0x42;
    

    This works. It is a workaround and I still don't know how to access mem above 0x7FFFFF but its OK for me as long as the CAN controller starts up.

    Thanks for your support!

Reply
  • Hi
    you didn't actually manage to set CMA=1.

    CMA was 1 all the time, I verified this in the startup code and with the debugger...

    But anyway, I've got the CAN-controller running now. While debugging, I noticed that r/w from/to absolute addresses above 0x7FFFFF doesn't work. So I did set CMA to 0 (CAN mem now @ 0x00DBxx) and access the mem like this:

    unsigned char far *can;
    ...
    //set C0BT0 = 0x42;
    can = &FVAR(unsigned char, 0x00DB04);
    *can = 0x42;
    

    This works. It is a workaround and I still don't know how to access mem above 0x7FFFFF but its OK for me as long as the CAN controller starts up.

    Thanks for your support!

Children
No data