修复busoff

This commit is contained in:
sunbeam 2023-07-18 17:03:00 +08:00
parent 4ddec6d207
commit cad8f3b8ac
7 changed files with 1484 additions and 1479 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +1,27 @@
QualityReport
2023年7月10日 16:44:36
2023年7月18日 11:22:56
------ Start build(ECU_APP, DefaultBuild) ------
E:\Program Files (x86)\renesas\CS+\CC\CC-RL\V1.11.00\Bin\ccrl.exe user\appTask.c -cpu=S3 -obj_path=DefaultBuild "-dev=E:\Program Files (x86)\renesas\CS+\CC\Device\RL78\Devicefile\DR5F10BBG.DVF" -g -g_line -I diagnose\DTC -I diagnose\CanTrcv -I sys -I . -I rscan_driver -I diagnose -I DataFlash -I CanNw -I diagnose\CanTp -I diagnose\CanIf -I user -D DEBUG1 -c -msg_lang=english
user\appTask.c(40):W0520172:External/internal linkage conflict with previous declaration
user\appTask.c(257):W0520177:Variable "num" was declared but never referenced
user\appTask.c(258):W0520177:Variable "keyPressCounter" was declared but never referenced
user\appTask.c(259):W0520177:Variable "LastKey" was declared but never referenced
user\appTask.c(399):W0523082:Pointer to the object of even alignment holds the odd address
user\appTask.c(403):W0520513:A value of type "MotorStateEE_Type __near *" cannot be assigned to an entity of type "uint8_t *"
user\appTask.c(441):W0520513:A value of type "MotorStateEE_Type __near *" cannot be assigned to an entity of type "uint8_t *"
user\appTask.c(677):W0523077:Called function should have prototype
user\appTask.c(731):W0523077:Called function should have prototype
E:\Program Files (x86)\renesas\CS+\CC\CC-RL\V1.11.00\Bin\rlink.exe -subcommand=DefaultBuild\ECU_APP.clnk
W0561017:The evaluation period of CC-RL V1 has expired. Please consider purchasing the product.
RAMDATA SECTION: 00000c41 Byte(s)
C:\Program Files (x86)\Renesas Electronics\CS+\CC\CC-RL\V1.11.00\Bin\ccrl.exe diagnose\extern.c -cpu=S3 -obj_path=DefaultBuild "-dev=C:\Program Files (x86)\Renesas Electronics\CS+\CC\Device\RL78\Devicefile\DR5F10BBG.DVF" -g -g_line -I diagnose\DTC -I diagnose\CanTrcv -I sys -I . -I rscan_driver -I diagnose -I DataFlash -I CanNw -I diagnose\CanTp -I diagnose\CanIf -I user -D DEBUG1 -c -msg_lang=english
diagnose\extern.c(107):W0520940:Missing return statement at end of non-void function "GetVoltage"
diagnose\extern.c(135):W0520940:Missing return statement at end of non-void function "GetMotorLockStatus"
diagnose\extern.c(181):W0520111:Statement is unreachable
diagnose\extern.c(322):W0520111:Statement is unreachable
diagnose\extern.c(326):W0520111:Statement is unreachable
diagnose\extern.c(330):W0520111:Statement is unreachable
diagnose\extern.c(334):W0520111:Statement is unreachable
diagnose\extern.c(505):W0520940:Missing return statement at end of non-void function "GetCanBusOffErr"
diagnose\extern.c(523):W0520940:Missing return statement at end of non-void function "GetBcmCommFault"
diagnose\extern.c(540):W0520940:Missing return statement at end of non-void function "GetAcpCommFault"
C:\Program Files (x86)\Renesas Electronics\CS+\CC\CC-RL\V1.11.00\Bin\rlink.exe -subcommand=DefaultBuild\ECU_APP.clnk
W0561016:The evaluation version of CC-RL V1 is valid for the remaining 59 days. After that, link size limit (64 Kbyte) will be applied. Please consider purchasing the product.
RAMDATA SECTION: 00000c45 Byte(s)
ROMDATA SECTION: 00000602 Byte(s)
PROGRAM SECTION: 000050bc Byte(s)
W0561017:The evaluation period of CC-RL V1 has expired. Please consider purchasing the product.
W0561017:The evaluation period of CC-RL V1 has expired. Please consider purchasing the product.
PROGRAM SECTION: 000050ad Byte(s)
W0561016:The evaluation version of CC-RL V1 is valid for the remaining 59 days. After that, link size limit (64 Kbyte) will be applied. Please consider purchasing the product.
W0561016:The evaluation version of CC-RL V1 is valid for the remaining 59 days. After that, link size limit (64 Kbyte) will be applied. Please consider purchasing the product.
Renesas Optimizing Linker Completed
------ Build ended(Error:0, Warning:12)(ECU_APP, DefaultBuild) ------
------ Build ended(Error:0, Warning:13)(ECU_APP, DefaultBuild) ------
--- CommandFile 1 ---
DefaultBuild\ECU_APP.clnk :
@ -67,14 +68,14 @@ DefaultBuild\ECU_APP.clnk :
-Input=DefaultBuild\hwCtrl.obj
-LIBrary=DataFlash\pfdl.lib
-SECURITY_ID=00000000000000000000
-DEVICE=E:\Program Files (x86)\renesas\CS+\CC\Device\RL78\Devicefile\DR5F10BBG.DVF
-DEVICE=C:\Program Files (x86)\Renesas Electronics\CS+\CC\Device\RL78\Devicefile\DR5F10BBG.DVF
-DEBug
-NOCOmpress
-NOOPtimize
-OUtput=DefaultBuild\ECU_APP.abs
-LIBrary=E:\Program Files (x86)\renesas\CS+\CC\CC-RL\V1.11.00\lib\rl78em4s.lib
-LIBrary=E:\Program Files (x86)\renesas\CS+\CC\CC-RL\V1.11.00\lib\malloc_n.lib
-LIBrary=E:\Program Files (x86)\renesas\CS+\CC\CC-RL\V1.11.00\lib\rl78em4r.lib
-LIBrary=C:\Program Files (x86)\Renesas Electronics\CS+\CC\CC-RL\V1.11.00\lib\rl78em4s.lib
-LIBrary=C:\Program Files (x86)\Renesas Electronics\CS+\CC\CC-RL\V1.11.00\lib\malloc_n.lib
-LIBrary=C:\Program Files (x86)\Renesas Electronics\CS+\CC\CC-RL\V1.11.00\lib\rl78em4r.lib
-OCDBG=04
-USER_OPT_BYTE=E933E8
-LISt=DefaultBuild\ECU_APP.map
@ -87,7 +88,7 @@ DefaultBuild\ECU_APP.clnk :
-NOLOgo
-end
-Input=DefaultBuild\ECU_APP.abs
-DEVICE=E:\Program Files (x86)\renesas\CS+\CC\Device\RL78\Devicefile\DR5F10BBG.DVF
-DEVICE=C:\Program Files (x86)\Renesas Electronics\CS+\CC\Device\RL78\Devicefile\DR5F10BBG.DVF
-OUtput=DefaultBuild\ECU_APP.mot
-FOrm=Stype
-REcord=S3
@ -95,7 +96,7 @@ DefaultBuild\ECU_APP.clnk :
-Message
-end
-Input=DefaultBuild\ECU_APP.abs
-DEVICE=E:\Program Files (x86)\renesas\CS+\CC\Device\RL78\Devicefile\DR5F10BBG.DVF
-DEVICE=C:\Program Files (x86)\Renesas Electronics\CS+\CC\Device\RL78\Devicefile\DR5F10BBG.DVF
-OUtput=output\ECU_APP.S19= A000-19FFF
-FOrm=Stype
-REcord=S3
@ -106,14 +107,14 @@ DefaultBuild\ECU_APP.clnk :
--- SHA1 hash value of output files ---
F:\FCB_project\temp\CFMOTOR\code\ECU_APP\DefaultBuild\ECU_APP.abs: 55d33179e85f16ad9069a3815f56f2006d257026
F:\FCB_project\temp\CFMOTOR\code\ECU_APP\DefaultBuild\ECU_APP.mot: 16cefa6c1006876a6879398951f3b1c9fd5a8571
F:\FCB_project\temp\CFMOTOR\code\ECU_APP\output\ECU_APP.S19: 767227f0b116eae5e54a14db699b85619ec56949
F:\FCBproject\temp\CFMOTOR\code\ECU_APP\DefaultBuild\ECU_APP.abs: da5250db10eaae5470bc6391d17bfd31e8a68fa6
F:\FCBproject\temp\CFMOTOR\code\ECU_APP\DefaultBuild\ECU_APP.mot: b9aee7806b80dded2182336249fb54227106182d
F:\FCBproject\temp\CFMOTOR\code\ECU_APP\output\ECU_APP.S19: 28cb884664bdee15517322073373c4cc33216913
--- System Information ---
*OS Version
Microsoft Windows 10 专业版 (-, 10.0.19044, WOW64)
Microsoft Windows 10 专业版 (-, 10.0.19045, WOW64)
*Language
中文(中国)
*.NET Framework Version
@ -133,16 +134,16 @@ F:\FCB_project\temp\CFMOTOR\code\ECU_APP\output\ECU_APP.S19: 767227f0b116eae5e54
*Product License
*Execution Place
E:\Program Files (x86)\renesas\CS+\CC
C:\Program Files (x86)\Renesas Electronics\CS+\CC
*Memory Usage
*Private Working Set
261 MB
239 MB
*Number of GDI Objects
2034
2057
*Number of USER Objects
1137
985
*Opened Files
2 editors, 2 files, 24 KB
1 editors, 1 files, 18 KB
--- Build Tool Plug-in Information ---
RH850 Build tool CC-RH Plug-in
@ -271,7 +272,7 @@ Device Information Common Interface
DeviceInformation.dll
--- Main Project Information ---
F:\FCB_project\temp\CFMOTOR\code\ECU_APP\ECU_APP.mtpj
F:\FCBproject\temp\CFMOTOR\code\ECU_APP\ECU_APP.mtpj
Microcontroller Information
*R5F10BBG
*File Name: Version

View File

@ -7,7 +7,7 @@
__far const unsigned char HD_VERSION[]={
'H' , //AC_HD_VERSION_00
'W' , //AC_HD_VERSION_01
'.' , //AC_HD_VERSION_06
'.' , //AC_HD_VERSION_06
'0' , //AC_HD_VERSION_02
'.' , //AC_HD_VERSION_03
'0' , //AC_HD_VERSION_04
@ -24,7 +24,7 @@ __far const unsigned char HD_VERSION[]={
};
__far const unsigned char SW_VERSION[]={
'S' , //AC_SW_VERSION_00
'S' , //AC_SW_VERSION_00
'W' , //AC_SW_VERSION_01
'.' , //AC_SW_VERSION_02
'0' , //AC_SW_VERSION_03
@ -33,13 +33,13 @@ __far const unsigned char SW_VERSION[]={
'1' , //AC_SW_VERSION_06
'.' , //AC_SW_VERSION_07
'0' , //AC_SW_VERSION_08
'3' , //AC_SW_VERSION_09
'4' , //AC_SW_VERSION_09
' ' , //AC_SW_VERSION_10
' ' , //AC_SW_VERSION_11
' ' , //AC_SW_VERSION_12
' ' , //AC_SW_VERSION_13
' ' , //AC_SW_VERSION_14
' ' , //AC_SW_VERSION_14
' ' , //AC_SW_VERSION_14
};
__far const unsigned char SUP_ECU_SW_VERSION[]={

View File

@ -146,7 +146,7 @@ void Timer_Pro(void)
Count_Down_Timer_16Bit(&DiagCnt);
uiNwTimCnt++;
uiNwToutCnt++; //网络管理定时器
uiNwToutCnt++; //网络管理定时器
if(uiNwRMSCnt > 0)
uiNwRMSCnt--;
if(uiNwLocWkpOffCnt > 0)

View File

@ -79,11 +79,11 @@ void __near RSCAN_INTCANGRECC_interrupt(void)
if ((RxCanMessage.IDL == CANTP_ADDR_PHY_REQ) || (RxCanMessage.IDL == CANTP_ADDR_FUNC_REQ))
{
if (RxCanMessage.IDL == CANTP_ADDR_FUNC_REQ && RxCanMessage.DB[1] == 0x3E && RxCanMessage.DB[2] == 0x80)
resetS3Server(); /*重置S3server计时*/
resetS3Server(); /*重置S3server计时*/
else
RxIndicationCanIf_Messages(0, RxCanMessage.IDL, RxCanMessage.DLC, RxCanMessage.DB);
DiagMsgRcvFlag = 1;
ucNwNetIdelCheck = 1; //网络空闲检测 300ms如果没有置位 默认为空闲
ucNwNetIdelCheck = 1; //网络空闲检测 300ms如果没有置位 默认为空闲
}
if ((RxCanMessage.IDL >= 0x0400) && (RxCanMessage.IDL <= 0x047F))
@ -91,7 +91,7 @@ void __near RSCAN_INTCANGRECC_interrupt(void)
{
ucRemoteWakupFlg = 1u;
RepeatMessageReq = RxCanMessage.DB[1] & 0x01;
ucNwNetIdelCheck = 1; //网络空闲检测 300ms如果没有置位 默认为空闲
ucNwNetIdelCheck = 1; //网络空闲检测 300ms如果没有置位 默认为空闲
}
if (RxCanMessage.IDL == 0x0403)
@ -127,8 +127,22 @@ void __near RSCAN_INTCAN0REC_interrupt(void)
{
}
extern unsigned char ucBusOffModeState;
uint8_t rec_count;
/* CAN Channel transmit */
void __near RSCAN_INTCAN0TRX_interrupt(void)
{
CFSTS0 &= 0xFFEF; /*Clear CFTXIF FIFO transmit interrupt request flag*/
if (ucBusOffModeState > 0)
{
rec_count++;
if (rec_count > 3)
{
ucBusOffModeState = 0;
}
}
else
{
rec_count = 0;
}
}

View File

@ -36,6 +36,7 @@ unsigned char ucIgnStus;
unsigned int uiBusOffCnt; // ms
unsigned char ucBusOffModeState; // 0:Normal 1~4:Fast Rec 5:Slow Rec
unsigned char BusoffFlag;
uint8_t maxBusOffTimes;
/***************************************************/
static unsigned int EEL_SAVE_CNT_DOWN_TIMER;
static uint8_t EEL_SAVE_ENABLE;
@ -60,15 +61,16 @@ void Apply_task(void)
Nw28sTxRxStatus = GetNetworkMsgSts();
// DiagnosticSession_Present=MngDcm_GetDiagnosticSession();
if(CAN_STB == 0 && BusOff_flag == 0)//Tx enable
{
TxServe();
}
if (Timer_1ms_flag == 1)
{
Timer_1ms_flag = 0;
MngDcm_MainFunction();
MngCanTp_MainFunction();
if(CAN_STB == 0 && uiBusOffCnt == 0)//Tx enable
{
TxServe();
}
if (BusOff_Detect_delay_count == 0 /*&& (ad_voltage_fact[2]>=85 && ad_voltage_fact[2]<=165)*/)
{
BusOff_Detect();
@ -387,7 +389,7 @@ void Can_Msg_Change(void)
CAN_212.Msg_Part.MSW_TogReq = toggle_req;
CAN_212.Msg_Part.MSW_BtnFltSts = 0;
CAN_212.Msg_Part.MSW_RotStep = xn_tx_num;
CAN_212.Msg_Part.Reserve_7 = ucBusOffModeState;
//CAN_212.Msg_Part.Reserve_7 = 0;//maxBusOffTimes;
}
static uint8_t EEL_BUF[50];
@ -507,97 +509,87 @@ void DID_data_save_init(void)
}
}
unsigned char BusOffTimeCnt = 0;
unsigned short BusOff1msCnt = 0;
unsigned char CanBusOffPro(void)
uint8_t checkBusOff(void)
{
unsigned char ret = 0;
if (C0ERFLLL & 0x08) // Bus-Off Stutas
if ( (C0ERFLL & 0x08) )// && (R_CAN_ReadChStatus_CH0() & 0x02)
{
ret = 1;
return 1;
}
if ((C0CTRLL & 0x02) == 0x02) // Channal Halt Mode
{
if (C0ERFLLL & 0x08) // Bus-Off Stutas
{
BusOff1msCnt++;
ret = 1;
}
if ((BusOffTimeCnt < 10) && (BusOff1msCnt >= 100))
{
BusOffTimeCnt++;
BusOff1msCnt = 0;
C0ERFLL = 0;
C0CTRL &= ~0x03; /* CHMDC[1:0] = 00B change to communication mode. */
}
else if ((BusOffTimeCnt >= 10) && (BusOff1msCnt >= 1000))
{
BusOffTimeCnt = 10;
BusOff1msCnt = 0;
C0ERFLL = 0;
C0CTRL &= ~0x03; /* CHMDC[1:0] = 00B change to communication mode. */
}
}
return ret;
return 0;
}
#define FAST_BUSOFF_THRESHOULD 50 // 100MS
#define SLOW_BUSOFF_THRESHOULD 200 // 100MS
uint8_t checkExitBusOff(void)
{
if ( (C0STSL & 0x10) == 0x10 )
{
//C0ERFLL &= ~0x10;
return 0;
}
return 1;
}
#define FAST_BUSOFF_THRESHOULD 49 // 50MS
#define SLOW_BUSOFF_THRESHOULD 199 // 200MS
void BusOff_Recovery(void);
#define BUSOFF_INIT 0
#define BUSOFF_IDLE 1
#define BUSOFF_WAIT 2
#define BUSOFF_RECOVER 3
void BusOff_Detect(void)
{
if ((C0ERFLL & 0x08) && (R_CAN_ReadChStatus_CH0() & 0x02))
static uint8_t netState=0,count;
static uint16_t powerupdelay=0;
switch (netState)
{
BusOff_flag = 1;
if (uiBusOffCnt == 0)
case BUSOFF_INIT:
powerupdelay++;
if (powerupdelay > 1000)
{
if (ucBusOffModeState == 0)
{
uiBusOffCnt = FAST_BUSOFF_THRESHOULD;
//BusOff_Recovery();
}
if ((ucBusOffModeState > 0) && (ucBusOffModeState < 5))
{
BusOff_Recovery();
uiBusOffCnt = FAST_BUSOFF_THRESHOULD; //fast recover
}
else if (ucBusOffModeState >= 5)
{
BusOff_Recovery();
uiBusOffCnt = SLOW_BUSOFF_THRESHOULD; //soft recover
}
else
{
;
}
netState = BUSOFF_IDLE;
}
break;
case BUSOFF_IDLE:
if (checkBusOff())
{
BusOff_flag = 1;
netState = BUSOFF_WAIT;
if (ucBusOffModeState < 5)
{
ucBusOffModeState++;
uiBusOffCnt = FAST_BUSOFF_THRESHOULD;
}
else
{
uiBusOffCnt = SLOW_BUSOFF_THRESHOULD; //soft recover
}
BusOff_Recovery();
air_req_timer = 0;
}
}
else
{
if (ucBusOffModeState > 0)
break;
case BUSOFF_WAIT:
if (uiBusOffCnt == 0)
{
if (uiBusOffCnt == 0)
netState = BUSOFF_RECOVER;
count = 0;
}
break;
case BUSOFF_RECOVER:
maxBusOffTimes = ucBusOffModeState;
if (BusOff_flag == 0 )
{
if (checkExitBusOff() == 1)
{
//ucBusOffModeState = 0;
// 原来程序的标志位
}
netState = BUSOFF_IDLE;
}
else
{
;
}
BusOff_flag = 0;
break;
default:
netState = BUSOFF_INIT;
break;
}
}
void BusOff_Recovery(void)

View File

@ -137,7 +137,7 @@ void TxServe(void)
//CAN_STB = 0;
if ((air_req_timer == 0) && ((App28sTxRxStatus & DCM28S_MASK_TX_DISABLE) != 0))//
{
BusOff_flag = 0;
Can_Msg_Change_Bcm();
re_flag = R_CAN_TrmByTRFIFO0_CH0(&TxCanMessage);