5、若上电期间 检查指出任何ESM组3错误 它是不安全的继续执行和微控制器的初始化过程可以停止在这一点上,假设没有任何ESM组3上电期间的错误 可以在这个序列中接下来的步骤 6、Check if any ESM group3 error was indicated during power-up. If any ESM group3 error occurred
during the power-up, it is not safe to continue code execution and the microcontroller initialization
process can be stopped at this point. The subsequent steps in this sequence assume that there was
no ESM group3 error during power-up.
6、 系统初始化
函数:systemInit();
文件 :system.c PDF:
6、 Initialize System - Clock, Flash settings with Efuse self check
7. Configure phase-locked loop (PLL) control registers with the largest value for the last-stage of the dividers (R-dividers)
8. Enable the PLLs
9. Run the eFuse controller start-up checks and start the self-test on the eFuse controller SECDED logic
10. Release the peripherals from reset and enable clocks to all peripherals
11. Set up the device-level multiplexing options as well as the input/output (I/O) multiplexing.
12. Wait for the eFuse controller ECC logic self-test to complete and check the results.
13. Set up the Flash module for the required wait states and pipelined mode
14. Set up the Flash bank and pump power modes
15. Trim the LPO
16. Run the self-test on the SECDED logic embedded inside the Flash module
17. Wait for main PLL output to become valid.
18. Map the device clock domains to the desired clock sources
19. Reduce the values of the R-dividers in steps to attain the target PLL output frequency for both PLL1 and PLL2.
void systemInit(void)
{
/* Configure PLL control registers and enable PLLs.
* The PLL takes (127 + 1024 * NR) oscillator cycles to acquire lock.
* This initialization sequence performs all the tasks that are not
* required to be done at full application speed while the PLL locks.
*/
setupPLL();
/* Run eFuse controller start-up checks and start eFuse controller ECC self-test.
* This includes a check for the eFuse controller error outputs to be stuck-at-zero.
*/
efcCheck();
/* Enable clocks to peripherals and release peripheral reset */
periphInit();
/* Configure device-level multiplexing and I/O multiplexing */
muxInit();
/* Wait for eFuse controller self-test to complete and check results */
if (!checkefcSelfTest()) /* eFuse controller ECC logic self-test failed */
{
efcClass2Error(); /* device operation is not reliable */
}
/** - Set up flash address and data wait states based on the target CPU clock frequency
* The number of address and data wait states for the target CPU clock frequency are specified
* in the specific part's datasheet.
*/
setupFlash();
/** - Configure the LPO such that HF LPO is as close to 10MHz as possible */
trimLPO();
/** - Wait for PLLs to start up and map clock domains to desired clock sources */
mapClocks();
/** - set ECLK pins functional mode */
systemREG1->SYSPC1 = 0U;
/** - set ECLK pins default output value */
systemREG1->SYSPC4 = 0U;
/** - set ECLK pins output direction */
systemREG1->SYSPC2 = 1U;
/** - set ECLK pins open drain enable */
systemREG1->SYSPC7 = 0U;
/** - set ECLK pins pullup/pulldown enable */
systemREG1->SYSPC8 = 0U;
/** - set ECLK pins pullup/pulldown select */
systemREG1->SYSPC9 = 1U;
/** - Setup ECLK */
systemREG1->ECPCNTL = (0U << 24U)
| (0U << 23U)
| ((8U - 1U) & 0xFFFFU);
7、 PBIST自检 函数:pbistSelfCheck()
文件 :sys_selftest.c PDF:
20. Run a diagnostic check on the CPU self-test controller . A CPU reset is asserted upon
completion of the CPU self-test. Therefore, the initialization steps leading up to the reset handler willbe repeated.
21. Run the built-in self-test for the CPU (LBIST) . A CPU reset is asserted upon completion
of the CPU self-test. Therefore, the initialization steps leading up to the reset handler will be repeated.
22. Run a diagnostic check on the CPU compare module (CCM-R4) .
23. Run a diagnostic check on the memory self-test controller .
24. Start a self-test on the CPU RAM using the programmable built-in self-test (PBIST) controller and wait for this self-test to complete and pass .
pbistSelfCheck();
/* Run PBIST on CPU RAM.
* The PBIST controller needs to be configured separately for single-port and dual-port SRAMs.
* The CPU RAM is a single-port memory. The actual "RAM Group" for all on-chip SRAMs is defined in the
* device datasheet.
*/
pbistRun(0x08300020, /* ESRAM Single Port PBIST */
PBIST_March13N_SP);
/* Wait for PBIST for CPU RAM to be completed */
while(!pbistIsTestCompleted());
/* Check if CPU RAM passed the self-test */
if( pbistIsTestPassed() != TRUE)
{
/* CPU RAM failed the self-test.
* Need custom handler to check the memory failure
* and to take the appropriate next step.
*/
if(pbistPortTestStatus(PBIST_PORT0) != TRUE)
{
memoryPort0TestFailNotification(pbistREG->RGS, pbistREG->RDS, pbistREG->FSRA0, pbistREG->FSRDL0);
}
else if(pbistPortTestStatus(PBIST_PORT1) != TRUE)
{
memoryPort1TestFailNotification(pbistREG->RGS, pbistREG->RDS, pbistREG->FSRA1, pbistREG->FSRDL1);
}
else
{
/* while(1) can be removed by adding "# if 0" and "# endif" in the user codes above and below */
while(1);
8、 初始化CPU RAM
函数:_memoryInit_(0x1);
文件 :sys_selftest.c PDF:
25. Initialize the CPU RAM using the system module hardware initialization mechanism so that the ECC region for the CPU RAM is also initialized .
/* Initialize CPU RAM.
* This function uses the system module's hardware for auto-initialization of memories and their
* associated protection schemes. The CPU RAM is initialized by setting bit 0 of the MSIENA register.
* Hence the value 0x1 passed to the function.
* This function will initialize the entire CPU RAM and the corresponding ECC locations.
*/
9、 启用TCRAM访问ECC检测
函数:_coreEnableRamEcc_()
文件 :sys_core.asm PDF:
26. Enable the CPU's SECDED logic for accesses to CPU RAM memory (CPU's B0TCM and B1TCM interfaces)
;-------------------------------------------------------------------------------
; Enable RAM ECC Support
public _coreEnableRamEcc_
10、开始PBIST在双端口存储器上自检
函数:void pbistRun(uint32_t raminfoL, uint32_t algomask)
文件 :sys_selftest.c PDF: 27. Start a self-test on all on-chip dual-port SRAMs using the PBIST controller
/* CPU RAM自检失败。需要自定义处理程序检查内存故障并采取适当的下一步.*/
if(pbistPortTestStatus(PBIST_PORT0) != TRUE)
{
memoryPort0TestFailNotification(pbistREG->RGS, pbistREG->RDS, pbistREG->FSRA0, pbistREG->FSRDL0);
}
else if(pbistPortTestStatus(PBIST_PORT1) != TRUE)
{
memoryPort1TestFailNotification(pbistREG->RGS, pbistREG->RDS, pbistREG->FSRA1, pbistREG->FSRDL1);
}
else
{
/* while(1) can be removed by adding "# if 0" and "# endif" in the user codes above and below */
/* 初始化所有片上SRAM的除MibSPIx RAM外
* The MibSPIx modules have their own auto-initialization mechanism which is triggered
* as soon as the modules are brought out of local reset.
*/
/* The system module auto-init will hang on the MibSPI RAM if the module is still in local reset.
*/
/* NOTE : Please Refer DEVICE DATASHEET for the list of Supported Memories and their channel numbers.
Memory Initialization is perfomed only on the user selected memories in HALCoGen's GUI SAFETY INIT tab.
*/
_memoryInit_( 1 << 1
| 1 << 2
| 1 << 5
| 1 << 6
| 1 << 10
| 1 << 8
| 1 << 14
| 1 << 3
| 1 << 4
| 1 << 15
| 1 << 16
| 0 << 13);
/* Test the parity protection mechanism for peripheral RAMs
NOTE : Please Refer DEVICE DATASHEET for the list of Supported Memories with parity.
Parity Self check is perfomed only on the user selected memories in HALCoGen's GUI SAFETY INIT tab.
*/
het1ParityCheck();
htu1ParityCheck();
het2ParityCheck();
htu2ParityCheck();
adc1ParityCheck();
adc2ParityCheck();
can1ParityCheck();
can2ParityCheck();
can3ParityCheck();
vimParityCheck();
dmaParityCheck();
while (mibspiREG1->BUFINIT); /* wait for MibSPI1 RAM to complete initialization */
while (mibspiREG3->BUFINIT); /* wait for MibSPI3 RAM to complete initialization */
while (mibspiREG5->BUFINIT); /* wait for MibSPI5 RAM to complete initialization */
PDF: 36. Enable the CPU’s dedicated vectored interrupt controller (VIC) port
37. Program all interrupt service routine addresses in the vectored interrupt manager (VIM) memory
38. Configure IRQ and FIQ interrupt priorities for all interrupt channels
39. Enable the desired interrupts (IRQ or FIQ) inside the CPU
40. Enable the desired interrupts in the VIM control registers
/* Enable IRQ offset via Vic controller */
_coreEnableIrqVicOffset_();