I'm using s32k144 and sometimes the can signal is sent from mcu. Also
I want to use VLPS mode and get out of VLPS mode using CAN RX (PTE4). I know that I can't just get out of VLPS mode using RX by referring to the data sheet.
1. I set up to enter VLPS after 5 seconds after I timed it with LPTMR and just before entering VLPS, I changed PTE4(RX) to GPIO and set PORTE interrupt. And while exiting VLPS, I disabled the interrupt again and changed PTE4 to MUX5.
But this is a problem, sometimes when the sleep counter reaches 5000, it zeroes the counter and doesn't enter the VLPS, it constantly rises 6000 10000. Of course, until this happens, the MCU wakes up when VECTOR gives a signal. When the constant counter rises, even if you press the WAKE switch, the counter goes to zero, but it constantly rises again and stops at the part where it reactivates the clock without WAKE. I need to re-energize the power.
May I know what the issue is? I never had this when I cleared the RX and PORTE related interrupt.
2. Sometimes an unwanted CAN signal is sent to the REMOTE type.
From the MCU to the VECTOR program.
My CAN code is part of the code I got from examples like COOKBOOK and Datasheet.
I try to post CAN code but I think I've erased all the REMOTE-related parts
void CAN0_Init(void)
{
#define MSG_BUF_SIZE 18 //버퍼 사이즈
uint32_t i=0;
//WDOG_disable();
PCC->PCCn[PCC_FlexCAN0_INDEX] |= PCC_PCCn_CGC_MASK; //CAN0 활성화
CAN0->MCR |= CAN_MCR_MDIS_MASK; //CAN 비활성화
CAN0->MCR |= CAN_MCR_MAXMB(31); //CAN 비활성화
CAN0->CTRL1 |= CAN_CTRL1_CLKSRC_MASK; //외부클럭 사용
CAN0->MCR &= ~CAN_MCR_MDIS_MASK; //CAN 활성화
while (!((CAN0->MCR & CAN_MCR_FRZACK_MASK) >> CAN_MCR_FRZACK_SHIFT)) {} //대기
CAN0->CBT = CAN_CBT_BTF_MASK|CAN_CBT_EPRESDIV(1)|CAN_CBT_EPSEG2(7)|CAN_CBT_EPSEG1(29)|CAN_CBT_EPROPSEG(0)|CAN_CBT_ERJW(7);
CAN0->FDCBT = CAN_CBT_EPSEG2(1)|CAN_CBT_EPSEG1(6)|CAN_CBT_EPROPSEG(0)|CAN_CBT_ERJW(1)|CAN_FDCBT_FPRESDIV(1);
CAN0->FDCTRL = CAN_FDCTRL_FDRATE_MASK|CAN_FDCTRL_MBDSR0(3)|CAN_FDCTRL_TDCEN_MASK|CAN_FDCTRL_TDCOFF(5);//CBT FDCBT클럭에 맞게
for(i=0; i<31; i++ ) { //메시지 버퍼 전체 초기화
CAN0->RAMn[i] = 0;
}
for(i=0; i<31; i++ ) {
CAN0->RXIMR[i] = 0xFFFFFFFF; //메시지 개별적 필터링인데 0x1FFFFFFF는 모든 메시지 허용
}
CAN0->RXMGMASK = 0x1FFFFFFF; //수신된 메시지가 버퍼로 저장되기 전 필터링 0x1FFFFFFF는 모든 메시지 허용
CAN0->RAMn[ 1*MSG_BUF_SIZE + 0] = 0xC4000000; //CS설정 데이터시트 1712페이지
CAN0->RAMn[ 1*MSG_BUF_SIZE + 1] = 0x04000000; //ID 0x100
CAN0->RAMn[ 2*MSG_BUF_SIZE + 0] = 0xC4000000; //CS설정 데이터시트 1712페이지
CAN0->RAMn[ 2*MSG_BUF_SIZE + 1] = 0x08940000; //ID 0x225
CAN0->RAMn[ 3*MSG_BUF_SIZE + 0] = 0xC4000000; //CS설정 데이터시트 1712페이지
CAN0->RAMn[ 3*MSG_BUF_SIZE + 1] = 0x15540000; //ID 0x555
CAN0->CTRL2 = CAN_CTRL2_ISOCANFDEN_MASK; //ISO CANFD 온
CAN0->MCR = 0x0000081F; //CAN FD 온 및
while ((CAN0->MCR && CAN_MCR_FRZACK_MASK) >> CAN_MCR_FRZACK_SHIFT) {}
while ((CAN0->MCR && CAN_MCR_NOTRDY_MASK) >> CAN_MCR_NOTRDY_SHIFT) {}
}
void CAN0RX(void)
{
uint8_t j;
//RxCODE = (CAN0->RAMn[ 4*MSG_BUF_SIZE + 0] & 0x07000000) >> 24; //CODE 7
//RxID = (CAN0->RAMn[ 4*MSG_BUF_SIZE + 1] & CAN_WMBn_ID_ID_MASK) >> CAN_WMBn_ID_ID_SHIFT ;
//RxLENGTH = (CAN0->RAMn[ 4*MSG_BUF_SIZE + 0] & CAN_WMBn_CS_DLC_MASK) >> CAN_WMBn_CS_DLC_SHIFT;
RxDATA[8] = CAN0->RAMn[ 1*MSG_BUF_SIZE + 10]; // 브레이크
if((RxDATA[8]&0x01000000)==0x01000000)
{
}
else
{
}
RxDATA2[0] = CAN0->RAMn[ 2*MSG_BUF_SIZE + 2]; // 0x225아이디로 첫번째 4바이트에서 맨 마지막 비트에 1,2,4 들어가면 정지 정 역
if((RxDATA2[0]&0x00000001)==0x00000001){
Direction=0;
}
else if((RxDATA2[0]&0x00000002)==0x00000002){
Direction=1;
}
else if((RxDATA2[0]&0x00000004)==0x00000004){
Direction=2;
}
for (j=0; j<2; j++) { //데이터 읽기 8바이트씩
RxDATA3[j] = CAN0->RAMn[ 3*MSG_BUF_SIZE + 2 + j];
}
//RxTIMESTAMP = (CAN0->RAMn[ 0*MSG_BUF_SIZE + 0] & 0x000FFFF);
CAN0->IFLAG1 = 0x00000010;
}
--------
When I activate PORTE interrupt for RX and WAKE with a switch or can, I get a problem where it's clock related.