Commit f3345a2c authored by hu's avatar hu

更改了RTC时间停止,以及里程大计异常问题

parent e94bb947
No preview for this file type
This diff is collapsed.
project .intvect 1536
project .text 316700
project .rodata 411095
project .text 317548
project .rodata 411087
project .secinfo 120
project .syscall 6
project .romdata 9029
......
......@@ -14,12 +14,12 @@ void RTE_RTC_KL30_Init(void)
void RTE_RTC_Wakeup_Init(void)
{
RTC_Init();
//RTC_Init();
}
void RTE_RTC_Services_100Ms_Cbk(void)
{
RTC_Timing_Service();
RTC_Get_Time();
}
......@@ -65,7 +65,7 @@ void RTE_RTC_Confirm_Overwrite(void)
mTimmerSetting.u8RTCMinute = RTE_RTC_MINUTE; /*0~~59 in Dec*/
mTimmerSetting.u8RTCSecond = RTE_RTC_SECOND; /*0~~59 in Dec*/
RTC_Set_Time(&mTimmerSetting);
RTC_Set_Time(mTimmerSetting.u8RTCYear, mTimmerSetting.u8RTCMonth, mTimmerSetting.u8RTCDayOfMonth, mTimmerSetting.u8RTCHour, mTimmerSetting.u8RTCMinute, mTimmerSetting.u8RTCSecond);
}
......@@ -103,4 +103,4 @@ uint8_t Get_RTC_SECOND(void)
uint8_t Get_RTC_WEEK(void)
{
return RTC_WEEK ;
}
\ No newline at end of file
}
This diff is collapsed.
#ifndef CLOCK_H__
#define CLOCK_H__
/*Oscillator*/
#define CLOCK_MAIN_OSC_FREQ_HZ (8000000UL)
#define CLOCK_SUB_OSC_FREQ_HZ (0UL) /*32768U*/
#define CLOCK_FAST_CR_OSC_FREQ_HZ (8000000UL)
#define CLOCK_SLOW_CR_OSC_FREQ_HZ (240000UL)
#define CLOCK_EMCLK_FREQ_HZ (CLOCK_FAST_CR_OSC_FREQ_HZ)
/* PLL */
#define CLOCK_PLL0_FREQ_HZ (480000000UL)
#define CLOCK_PLL1_FREQ_HZ (480000000UL)
#define CLOCK_PLLFIX_FREQ_HZ (CLOCK_PLL1_FREQ_HZ)
#define CLOCK_JIT_FREQ_HZ (80000000UL)
#define CLOCK_FIX_FREQ_HZ (80000000UL)
#define CLOCK_SDRB_FREQ_HZ (240000000UL)
#define CLOCK_CPU_FREQ_HZ (240000000UL)
#define CLOCK_XC_FREQ_HZ (120000000UL)
#define CLOCK_PCLK_FREQ_HZ (CLOCK_XC_FREQ_HZ / 2)
#define CLOCK_ETNBP_FREQ_HZ (60000000UL) /*Enable or Disable*/
#define CLOCK_ETNBXC_FREQ_HZ (120000000UL) /*Enable or Disable*/
#define CLOCK_RSCANP_FREQ_HZ (80000000UL) /*Enable or Disable*/
#define CLOCK_AWOT_FREQ_HZ (8000000UL)
#define CLOCK_WDTA0_FREQ_HZ (240000UL)
#define CLOCK_RTCA_FREQ_HZ (4000000UL)
#define CLOCK_FOUT_FREQ_HZ (20000000UL)
#define CLOCK_SFMA_FREQ_HZ (240000000UL)
#define CLOCK_RSCAN_FREQ_HZ (40000000UL)
#define CLOCK_RSCANXIN_FREQ_HZ (16000000UL) /*MAIN_OSC or Disable*/
#define CLOCK_SSIF_FREQ_HZ (50000000UL)
#define CLOCK_TAUB01_FREQ_HZ (80000000UL)
#define CLOCK_TAUB2_FREQ_HZ (80000000UL)
#define CLOCK_TAUJ_FREQ_HZ (80000000UL)
#define CLOCK_OSTM_FREQ_HZ (80000000UL)
/*#define CLOCK_LCBI_FREQ_HZ (CLOCK_JIT_FREQ_HZ)*/
#define CLOCK_ADCE_FREQ_HZ (40000000UL)
#define CLOCK_ISM_FREQ_HZ (80000000UL)
#define CLOCK_RLIN_FREQ_HZ (48000000UL)
/* Registers */
#define CLOCK_CFG_CLKJIT_DIVIDER (0x0001010FUL)
#define CLOCK_CFG_CLKJIT_SOURCE (0x00210100UL)
#define CLOCK_CFG_CLKJIT_ACTIVE (0x00210100UL)
typedef enum
{
CLOCK_STARTUP_PWR_ON = 0,
CLOCK_STARTUP_WAKE_UP,
CLOCK_STARTUP_SYSTEM_RESET,
} Clock_Startup_Mode_en_t;
extern void Clock_Pre_Init(void);
extern void Clock_Init(void);
extern void Clock_Enter_Sleep_Mode(void);
extern Clock_Startup_Mode_en_t Clock_Get_Startup_Mode(void);
extern void Sys_Enter_Sleep_Mode(void);
#endif
#ifndef CLOCK_H__
#define CLOCK_H__
/*Oscillator*/
#define CLOCK_MAIN_OSC_FREQ_HZ (8000000UL)
#define CLOCK_SUB_OSC_FREQ_HZ (0UL) /*32768U*/
#define CLOCK_FAST_CR_OSC_FREQ_HZ (8000000UL)
#define CLOCK_SLOW_CR_OSC_FREQ_HZ (240000UL)
#define CLOCK_EMCLK_FREQ_HZ (CLOCK_FAST_CR_OSC_FREQ_HZ)
/* PLL */
#define CLOCK_PLL0_FREQ_HZ (480000000UL)
#define CLOCK_PLL1_FREQ_HZ (480000000UL)
#define CLOCK_PLLFIX_FREQ_HZ (CLOCK_PLL1_FREQ_HZ)
#define CLOCK_JIT_FREQ_HZ (80000000UL)
#define CLOCK_FIX_FREQ_HZ (80000000UL)
#define CLOCK_SDRB_FREQ_HZ (240000000UL)
#define CLOCK_CPU_FREQ_HZ (240000000UL)
#define CLOCK_XC_FREQ_HZ (120000000UL)
#define CLOCK_PCLK_FREQ_HZ (CLOCK_XC_FREQ_HZ / 2)
#define CLOCK_ETNBP_FREQ_HZ (60000000UL) /*Enable or Disable*/
#define CLOCK_ETNBXC_FREQ_HZ (120000000UL) /*Enable or Disable*/
#define CLOCK_RSCANP_FREQ_HZ (80000000UL) /*Enable or Disable*/
#define CLOCK_AWOT_FREQ_HZ (8000000UL)
#define CLOCK_WDTA0_FREQ_HZ (240000UL)
#define CLOCK_RTCA_FREQ_HZ (4000000UL)
#define CLOCK_FOUT_FREQ_HZ (20000000UL)
#define CLOCK_SFMA_FREQ_HZ (240000000UL)
#define CLOCK_RSCAN_FREQ_HZ (40000000UL)
#define CLOCK_RSCANXIN_FREQ_HZ (16000000UL) /*MAIN_OSC or Disable*/
#define CLOCK_SSIF_FREQ_HZ (50000000UL)
#define CLOCK_TAUB01_FREQ_HZ (80000000UL)
#define CLOCK_TAUB2_FREQ_HZ (80000000UL)
#define CLOCK_TAUJ_FREQ_HZ (80000000UL)
#define CLOCK_OSTM_FREQ_HZ (80000000UL)
/*#define CLOCK_LCBI_FREQ_HZ (CLOCK_JIT_FREQ_HZ)*/
#define CLOCK_ADCE_FREQ_HZ (40000000UL)
#define CLOCK_ISM_FREQ_HZ (80000000UL)
#define CLOCK_RLIN_FREQ_HZ (48000000UL)
/* Registers */
#define CLOCK_CFG_CLKJIT_DIVIDER (0x0001010FUL)
#define CLOCK_CFG_CLKJIT_SOURCE (0x00210100UL)
#define CLOCK_CFG_CLKJIT_ACTIVE (0x00210100UL)
typedef enum
{
CLOCK_STARTUP_PWR_ON = 0,
CLOCK_STARTUP_WAKE_UP,
CLOCK_STARTUP_SYSTEM_RESET,
} Clock_Startup_Mode_en_t;
extern void Clock_Pre_Init(void);
extern void Clock_Init(void);
extern void Clock_Enter_Sleep_Mode(void);
extern Clock_Startup_Mode_en_t Clock_Get_Startup_Mode(void);
extern void Sys_Enter_Sleep_Mode(void);
#endif
This diff is collapsed.
#ifndef RTC_H__
#define RTC_H__
#include "r_typedefs.h"
#define RTC_MODE_MAIN 0U
#define RTC_MODE_SUB 1U
#define RTC_MODE_SELECT RTC_MODE_MAIN
/* RTC default time setting */
#ifndef RTC_DEFAULT_TIME
#define RTC_DEFAULT_TIME 1U
#define RTC_DEFAULT_YEAR 21U
#define RTC_DEFAULT_MONTH 1U
#define RTC_DEFAULT_DATE 1U
#define RTC_DEFAULT_HOUR 0U
#define RTC_DEFAULT_MINUTE 0U
#define RTC_DEFAULT_SECOND 0U
#endif
typedef struct
{
uint8_t u8RTCYear; /*00~~99 in Dec*/
uint8_t u8RTCMonth; /*01~~12 in Dec*/
uint8_t u8RTCDayOfMonth; /*01~~31 in Dec*/
uint8_t u8RTCHour; /*fix 24Hour Format 00~~23 in Dec*/
uint8_t u8RTCMinute; /*0~~59 in Dec*/
uint8_t u8RTCSecond; /*0~~59 in Dec*/
uint8_t u8RTCWeek ; /*1~7 in Dec*/
} RTC_Information_st_t;
extern volatile uint8_t g_RTCLeapYear; /*1:LeapYear , 0:Not a leap year*/
extern volatile RTC_Information_st_t g_stRTCInformation;
/* RTC exported time register */
#define RTC_YEAR g_stRTCInformation.u8RTCYear
#define RTC_MONTH g_stRTCInformation.u8RTCMonth
#define RTC_DATE g_stRTCInformation.u8RTCDayOfMonth
#define RTC_HOUR g_stRTCInformation.u8RTCHour
#define RTC_MINUTE g_stRTCInformation.u8RTCMinute
#define RTC_SECOND g_stRTCInformation.u8RTCSecond
#define RTC_WEEK g_stRTCInformation.u8RTCWeek
#define RTC_LEAP_YEAR g_RTCLeapYear
extern void RTC_Pre_Init(void);
extern void RTC_Init(void);
extern void RTC_Set_Time(RTC_Information_st_t *pstRTCTime);
extern void RTC_Timing_Service(void);
#endif
#ifndef RTC_H__
#define RTC_H__
#include "r_typedefs.h"
#define RTC_MODE_MAIN 0U
#define RTC_MODE_SUB 1U
#define RTC_MODE_SELECT RTC_MODE_MAIN
//#ifndef RTC_DEFAULT_TIME
#define RTC_DEFAULT_TIME 1U
#define RTC_DEFAULT_YEAR 21U
#define RTC_DEFAULT_MONTH 1U
#define RTC_DEFAULT_DATE 1U
#define RTC_DEFAULT_HOUR 0U
#define RTC_DEFAULT_MINUTE 0U
#define RTC_DEFAULT_SECOND 0U
//#endif
typedef struct
{
uint8_t u8RTCYear; /*00~~99 in Dec*/
uint8_t u8RTCMonth; /*01~~12 in Dec*/
uint8_t u8RTCDayOfMonth; /*01~~31 in Dec*/
uint8_t u8RTCHour; /*fix 24Hour Format 00~~23 in Dec*/
uint8_t u8RTCMinute; /*0~~59 in Dec*/
uint8_t u8RTCSecond; /*0~~59 in Dec*/
uint8_t u8RTCWeek ; /*1~7 in Dec*/
} RTC_Information_st_t;
extern RTC_Information_st_t g_stRTCInformation;
/* RTC exported time register */
#define RTC_YEAR g_stRTCInformation.u8RTCYear
#define RTC_MONTH g_stRTCInformation.u8RTCMonth
#define RTC_DATE g_stRTCInformation.u8RTCDayOfMonth
#define RTC_HOUR g_stRTCInformation.u8RTCHour
#define RTC_MINUTE g_stRTCInformation.u8RTCMinute
#define RTC_SECOND g_stRTCInformation.u8RTCSecond
#define RTC_WEEK g_stRTCInformation.u8RTCWeek
#define RTC_LEAP_YEAR g_RTCLeapYear
extern void RTC_Pre_Init(void);
//extern void RTC_Set_Time(uint16_t day, uint8_t hour, uint8_t minute, uint8_t second);
extern void RTC_Set_Time(uint8_t year, uint8_t month, uint16_t day, uint8_t hour, uint8_t minute, uint8_t second);
extern void RTC_Get_Time(void);
extern void RTC_Backup_Time(void);
extern void Rtc_Restore_Time(void);
#endif
This diff is collapsed.
#ifndef TYW_FLASH_H
#define TYW_FLASH_H
#include"stdint.h"
typedef enum
{
R_SFMA0_ERR_OK = 0,
R_SFMA0_ERR_NG,
R_SFMA0_ERR_PARAM_INCORRECT,
R_SFMA0_ERR_RANGE_UNIT,
R_SFMA0_ERR_RANGE_PARAM,
R_SFMA0_ERR_NOT_ACCEPTABLE,
R_SFMA0_ERR_FATAL_OS,
R_SFMA0_ERR_FATAL_HW,
R_SFMA0_ERR_NOT_SUPPORT_CLOCK,
R_SFMA0_ERR_NOT_SUPPORT_TRANSFER,
R_SFMA0_ERR_SFLASH_PROTECTED,
R_SFMA0_ERR_NOT_SUPPORTED
} r_sfma0_Error_t;
typedef struct
{
uint8_t DTR_CMD;
uint8_t DTR_MF0_7;
uint8_t DTR_DummyCycle;
}SFMA_DDR_Parameter_t;
void TYW_FLASH_Init(void);
void TYW_FLASH_PreInit(void);
void TYW_FLASH_DDRPreInit(SFMA_DDR_Parameter_t *DDR_Parameter);
#ifndef TYW_FLASH_H
#define TYW_FLASH_H
//#include"stdint.h"
#include "r_typedefs.h"
typedef enum
{
R_SFMA0_ERR_OK = 0,
R_SFMA0_ERR_NG,
R_SFMA0_ERR_PARAM_INCORRECT,
R_SFMA0_ERR_RANGE_UNIT,
R_SFMA0_ERR_RANGE_PARAM,
R_SFMA0_ERR_NOT_ACCEPTABLE,
R_SFMA0_ERR_FATAL_OS,
R_SFMA0_ERR_FATAL_HW,
R_SFMA0_ERR_NOT_SUPPORT_CLOCK,
R_SFMA0_ERR_NOT_SUPPORT_TRANSFER,
R_SFMA0_ERR_SFLASH_PROTECTED,
R_SFMA0_ERR_NOT_SUPPORTED
} r_sfma0_Error_t;
typedef struct
{
uint8_t DTR_CMD;
uint8_t DTR_MF0_7;
uint8_t DTR_DummyCycle;
}SFMA_DDR_Parameter_t;
void TYW_FLASH_Init(void);
void TYW_FLASH_PreInit(void);
void TYW_FLASH_DDRPreInit(SFMA_DDR_Parameter_t *DDR_Parameter);
extern uint32_t TestBackupRam;
#endif
\ No newline at end of file
This diff is collapsed.
......@@ -82,6 +82,11 @@ void Sys_Startup_Pre_Init(void)
* \attention
* \retval None
******************************************************************************/
uint8_t u8ResetFlag = 0;
extern uint32_t u32ResetFlag;
extern uint32_t TestBackupRam;
void Sys_Startup_Init(void)
{
Clock_Init();
......@@ -97,7 +102,7 @@ void Sys_Startup_Init(void)
CPU_Init();
RTC_Init();
//RTC_Init();
Sys_Tick_Timer_Start();
/*COM_CAN_Init(); Ô­CAN³õʼ»¯Î»ÖÃ*/
......@@ -117,10 +122,26 @@ void Sys_Startup_Init(void)
ReadDTCEOLValue_Meter_K_LINE();
d_printf("Init complete!\n");
InitSeriFlashExternReadMode();
//APP_Startup_Init(Clock_Get_Startup_Mode());
u8ResetFlag = Clock_Get_Startup_Mode();
if (u32ResetFlag != 0xA55AA55AUL)
{
u8ResetFlag = 0;
}
else
{
if ((u8ResetFlag == 0) && (TestBackupRam == 0xaabbccddu))
{
u8ResetFlag = 1;
Rtc_Restore_Time();
}
}
/*30电初始化*/
APP_Startup_Init(u8ResetFlag);
TestBackupRam = 0x11223344UL;
InitSeriFlashExternReadMode();
/*30电数据初始化*/
APP_Startup_Init(Clock_Get_Startup_Mode());
/*外发要用到EEP数据,位置移动*/
COM_CAN_Init();
Gfx_Sys_Start();
......
#include "r_typedefs.h"
#include "sys_scheduler.h"
#include "Watchdog.h"
extern uint32_t u32ResetFlag;
int main(void)
{
Sys_Init();
while (1U)
{
u32ResetFlag = 0xA55AA55AUL;
Sys_Scheduling_Service();
WDT_Clear();
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment