在线时间828 小时
UID3079326
注册时间2015-2-11
NXP金币29
TA的每日心情 | 奋斗 2025-5-7 09:07 |
---|
签到天数: 353 天 连续签到: 1 天 [LV.8]以坛为家I
金牌会员
 
- 积分
- 5786
- 最后登录
- 2025-5-7
|
本帖最后由 wambob 于 2017-6-26 21:43 编辑
看了双核的资料,有了一点点认识。SDK里给了几个多核例程,先跑个例程熟悉下。
先打开hello_world_cm4,然后再把hello_world_cm0plus添加进来
结果如下:
设置好每个工程的debug选项
先编译cm0核工程,再编译CM4工程。这个例程的目的是cm4核运行中启动cm0核并检测开关状态,按开关SW1,停止CM0核,按SW2启动CM0核,使LED闪烁,。
先修改两个开关。
对应的管脚
使用两个开关替换原例程,比如KEY0、KEY1。
然后点图标进去debug
除了原来的工程外,又自动打开了CM0工程,如上图,和普通的IAR调试界面,工具栏有了变化。
不能全速运行了,而且多出双核启动和停止等工具。先打开串口,单步看看发生了什么
cm4主函数
- int main(void)
- {
- /* Define the init structure for the switches*/
- gpio_pin_config_t sw_config = {kGPIO_DigitalInput, 0};
- /* Init board hardware.*/
- /* attach 12 MHz clock to FLEXCOMM0 (debug console) */
- CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0);
- BOARD_InitPins_Core0();
- BOARD_BootClockFROHF48M();
- BOARD_InitDebugConsole();
- /* Init switches */
- GPIO_PinInit(BOARD_SW1_GPIO, BOARD_SW1_GPIO_PORT, BOARD_SW1_GPIO_PIN, &sw_config);
- GPIO_PinInit(BOARD_SW2_GPIO, BOARD_SW2_GPIO_PORT, BOARD_SW2_GPIO_PIN, &sw_config);
- #ifdef CORE1_IMAGE_COPY_TO_RAM
- /* Calculate size of the image - not required on LPCExpresso. LPCExpresso copies image to RAM during startup
- * automatically */
- uint32_t core1_image_size;
- core1_image_size = get_core1_image_size();
- PRINTF("Copy Secondary core image to address: 0x%x, size: %d\n", CORE1_BOOT_ADDRESS, core1_image_size);
- /* Copy Secondary core application from FLASH to RAM. Primary core code is executed from FLASH, Secondary from RAM
- * for maximal effectivity.*/
- memcpy(CORE1_BOOT_ADDRESS, (void *)CORE1_IMAGE_START, core1_image_size);
- #endif
- /* Initialize MCMGR before calling its API */
- MCMGR_Init();
- /* Boot Secondary core application */
- PRINTF("Starting Secondary core.\n");
- MCMGR_StartCore(kMCMGR_Core1, CORE1_BOOT_ADDRESS, 1, kMCMGR_Start_Synchronous);
- /* Print the initial banner from Primary core */
- PRINTF("\r\nHello World from the Primary Core!\r\n\n");
- PRINTF("Press the SW1 button to Stop Secondary core.\r\n");
- PRINTF("Press the SW2 button to Start Secondary core.\r\n");
- while (1)
- {
- /* Stop secondary core execution. */
- if (!GPIO_ReadPinInput(BOARD_SW1_GPIO, BOARD_SW1_GPIO_PORT, BOARD_SW1_GPIO_PIN))
- {
- MCMGR_StopCore(kMCMGR_Core1);
- PRINTF("Stopped Secondary core.\r\n");
- delay();
- }
- /* Start core from reset vector */
- if (!GPIO_ReadPinInput(BOARD_SW2_GPIO, BOARD_SW2_GPIO_PORT, BOARD_SW2_GPIO_PIN))
- {
- MCMGR_StartCore(kMCMGR_Core1, CORE1_BOOT_ADDRESS, 5, kMCMGR_Start_Synchronous);
- PRINTF("Started Secondary core.\r\n");
- delay();
- }
- }
- }
复制代码
串口信息已经打印了已经启动了cm0核,CM0工程的while循环
- while (1)
- {
- delay();
- LED_TOGGLE();
- }
复制代码 板上的LED6闪烁。LED灯闪烁的代码不在CM4工程里而是在CM0工程里。通过上面的工程,也许已经看出和普通的工程多了mcmgr。
这个是多核管理中间件。
停止DEBUG后,复位,不能启动CM0核,需要重新上电才能。
|
|