在线时间109 小时
UID3332856
注册时间2016-11-28
NXP金币378
TA的每日心情 | 擦汗 2024-11-7 09:48 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]初来乍到
金牌会员
 
- 积分
- 1263
- 最后登录
- 2025-8-26
|
本帖最后由 北方. 于 2017-6-29 16:28 编辑
1、使用keil比较方便,因为这个板子是Jlink的版本和xprosso不大兼容,连接时内存位置需要额外定制。
2.、用例程中的双核hello-world,首先需要打开cm0的例程,并编译生成.bin文件,在cm4中的文件会自动读取这个bin文件并一起编译下载
3、然后,打开cm4,这里会看到对应的配置文件,把cm0引入
对应的代码如下:
运行后,可以在cm4中控制cm0的操作,用sw1,和sw2,可以分别启动停止cm0 的操作
使用起来还是非常方便的。
附:
cm0的点灯程序,- int main(void)
- {
- uint32_t startupData, i;
- /* Define the init structure for the output LED pin*/
- gpio_pin_config_t led_config = {
- kGPIO_DigitalOutput, 0,
- };
- /* Initialize MCMGR before calling its API */
- MCMGR_Init();
- /* Get the startup data */
- MCMGR_GetStartupData(kMCMGR_Core1, &startupData);
- /* Make a noticable delay after the reset */
- /* Use startup parameter from the master core... */
- for (i = 0; i < startupData; i++)
- delay();
- /* Init board hardware.*/
- /* enable clock for GPIO */
- CLOCK_EnableClock(kCLOCK_Gpio0);
- CLOCK_EnableClock(kCLOCK_Gpio1);
- BOARD_InitPins_Core1();
- /* Configure LED */
- LED_INIT();
- /* Signal the other core we are ready */
- MCMGR_SignalReady(kMCMGR_Core1);
- while (1)
- {
- delay();
- LED_TOGGLE();
- }
- }
复制代码
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.\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.\n");
- delay();
- }
- }
- }
复制代码
|
|