SCI0 & MSCAN0 routing problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SCI0 & MSCAN0 routing problem

953 Views
thulzh
Contributor III

Hello,

I am now using the S12ZVC12F0VKH. I tried to route the TXCAN0/RXCAN0 to pin PS3/2 while at the same time route TXD0/RXD0 to pin PS1/0. I set the MODRR0_M0C0RR = 0b110 and MODRR0_SCI0RR = 1. When I test on the S12ZVC-DEVKIT, the MSCAN works well while SCI0 does not work. According to the figure 2-2 on S12ZVC_RM.pdf, I wonder if the PS1/2 are routed to CPTXD0/CPRXD0 and can not be routed to SCI0 in the way I set the registers.

Labels (1)
4 Replies

858 Views
kef2
Senior Contributor IV

According to Fig. 2-2 MOC0RR2:1 = 11 not only route MSCAN0 to TXCAN0/RXCAN0 pins, but also route CAN PHY CPU side pins to CPTXD0 and CPRXD0 (PS1:0).

I tried toggling PS1:0 GPIO with MOC0RR2:1 set to 11. It works until CANPHY is enabled. So I guess you have CAN PHY enabled and this blocks SCI0 on PS1:0.

Edward

0 Kudos

858 Views
thulzh
Contributor III

Thank you. I have do the same test and also succeeded in toggling the PS1:0.

According to this phenomenon, I set the MODRR0_M0C0RR = 0b110, MODRR0_SCI0RR = 1 as well as DDRS_DDRS1:0 = 1(configured as output). Then I tried to send out message through SCI0 in PS1:0. 

After I download the project into S12DEVKIT, I run the project under debug mode (CW11.1) and the MSCAN on PS2/3 and SCI0 on PS1/0 both worked well.

Then I terminated in the debug mode, unpluged the USB and pressed the reset button to make the MCU work in normal mode. It turned out that the MSCAN still worked well on PS2/3 but the SCI0 did not work well on PS1/0 while SCI0 worked well on PJ0/1.

The same code has different results in the debug mode and normal mode. How to analyze this problem? 

Zhenghong

0 Kudos

858 Views
kef2
Senior Contributor IV

Hi,

CAN PHY isn't enabled by default in normal mode, and my code to set up MODRR0 then keep toggling works well standalone. But you should make sure CAN PHY isn't enabled by some part of your code.

Since you modified MODRR0, chances are you set up it wrong way. MODRR0 is write once (in normal mode) register, which means you need to write all bits as desired at once. You can't set up MODRR0 bits for CAN routing, then set up SCI0 bit for SCI0 routing. 2nd and further writes are ignored in normal mode. You need to write all MODRR0 bits in the same asm/C instruction.

What's interesting some MODRR registers are write once and some have unrestricted writes. Next time you project works in debugger and doesn't work standalone you should search through RM to find write once registers and bits in question.

Edward

858 Views
thulzh
Contributor III

Wonderful! Thanks a lot!

The write once operation solved the problem!

Before this, although I have noticed this note on the RM, I can not understand what it means actually. Now, I get it!

Zhenghong

0 Kudos