|
【LPC54100】+ 初识Dual Core
[复制链接]
拿到板子也蛮多时间的了,一直没时间写点什么东西, 话说也是第一次弄NXP的U,挺新鲜的。基本开发环境搭建OK,官方资源熟悉也差不多了,看了一下dual core的examlpe。写个帖子说说自己对LPC541000的一些认识吧。
可以看到一些比较新的东西,core单元有两个内核,算是最大的特点了,双核嘛。简单理解,两个IC封装到一起了,该干嘛还是该干嘛,做了一些两个IC之间通信的机制也就是这里的mailbox咯。不过对于这种封装到一起的双核而言,他们的外设是共享的,就是说本来我有个SPI,你有个I2C,封装到一起了嘛,那好,资源共享咯。共享资源是可以的,要商量好,那么自然需要一种机制提供服务管理,也就是所谓的mutex互斥锁,从dual core的例子的readme中可以看出,这算是个硬件的锁,可控的,提供一些用户接口罢了。
恩,在说说ROM这个地方,也是老手段了,不过也算是NXP的惯用手段,之前了解过NXP的LPC1114C系列内置canopen协议栈,也算是和蔼亲切了,搞过canopen的或者看过canopen协议的应该能明白NXP的用心良苦。这里ROM主要提供两个服务,low-power API和drivers,恩也蛮真实的,不能都open出来,别的IC厂家眼红着呢,玩点神秘也是好的,可惜稍微懂点U的人,看看就知道了,没啥玄机。归根就低还是需要熟悉了解某一款U的启动过程,比较真实的,贴切的认识的那种,保证你在N核的时候都不紧张。
接着说说,这些个dual core是如何来run的,太简单了。就是两个IC,如何run随你啦,也就是是00/01/10/11的组合嘛,可惜有内置在ROM中的原始引导程序,起码在power-on的时候有个起始位置就行了。哦,那行了,随意让一个先起来吧,NXP选择采用M4先起来,然后嘛,继续运行M0也是随你的了。RAM和FLASH嘛,这玩意还是和LD有关系,不懂的就没得说了,可以理解每个IC都有自己的RAM和FLASH,然后嘛封装在一起这些个RAM和FLASH也合并一下嘛,只不过是在LD的时候分别指定自己的memory空间就噢了,画了个小图,简单看下。
这个LD嘛,拿比较熟悉的IAR说事情,也就是ICF文件咯,分别看一下multicore中的M4和M0的ICF文件
\lpcopen_2_14_1_keil_iar_lpcxpresso_54102\applications\lpc5410x\examples\multicore\m4master_blinky\LPC540xx_m4_map.icf
- define symbol __ICFEDIT_intvec_start__ = 0x00000000;
- /*-Memory Regions-*/
- define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
- define symbol __ICFEDIT_region_ROM_end__ = 0x0001FFFF;
- define symbol __ICFEDIT_region_RAM_start__ = 0x02000000;
- define symbol __ICFEDIT_region_RAM_end__ = 0x02007FFF;
复制代码
\lpcopen_2_14_1_keil_iar_lpcxpresso_54102\applications\lpc5410x\examples\multicore\m0slave_blinky\LPC540xx_m0_map.icf
- define symbol __ICFEDIT_intvec_start__ = 0x00020000;
- /*-Memory Regions-*/
- define symbol __ICFEDIT_region_ROM_start__ = 0x00020000;
- define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
- define symbol __ICFEDIT_region_RAM_start__ = 0x02008000;
- define symbol __ICFEDIT_region_RAM_end__ = 0x0200FFFF;
复制代码
恩,其实你可以随意的,不过需要注意一点就是M4的ROMstart地址需要是0x00000000,哎这货还没太注意,直接是0的位置,那么他应该不内置BL咯,挺好的会自由很多。
最后我们细心的看一下官方的文字吧,最喜欢这种txt文档,说道理不含糊,喜欢老外的做事风格,记录的这么细。要是换做是国产IC你别指望这么细咯。
\lpcopen_2_14_1_keil_iar_lpcxpresso_54102\applications\lpc5410x\examples\multicore\m4master_blinky\readme.txt
- Multicore blinky example (M4 core as master, M0 as slave)
- =========================================================
- Example description
- -------------------
- This multicore example sets up the M4 core as the MCU master that communicates with
- the M0 core running as a slave. This project is meant to work with the m0slave_blinky
- project as the slave and the m4master_blinky project as the master.
- When this example works correctly and both cores are running, board LEDs 0 and 1
- will toggle at about 1Hz. When one LED is on, the other LED is off.
- What this example does: m4master_blinky
- - Sets up the system via SystemInit() and initializes the board layer via Board_Init()
- The M0 slave does not repeat this step.
- - Shares a 32-bit value bewteen both cores that contains LED on/off state for board
- LEDs 0 and 1 in bit position 0 for the master and bit position 1 for the slave. A
- 0 or 1 in these bit locations indicates the LED off(0) or on(1) state for board
- LEDs 0 or 1, respectively.
- - Sets up the mailbox and hardware mutex. This is only performed once by the master
- core. Enables the mailbox interrupt.
- - Initializes the M0 slave core boot entry address and stack pointer. The startup
- code for both the M0 and M4 cores is shared with the M0 core being placed into a
- safe, low power state. Once the master sets up the necessary addresses, the M0
- slave core is reset and boots with the address and stack given by the master.
- Note the shared M0/M4 startup code handles this part of the boot sequence.
- - Grabs the hardware mutex for the shared LED state value.
- - Sets up a periodic system tick event which toggles the LED0 state value at about
- 1Hz. This doesn't yet toggle board LED0 yet, only the state value.
- - Triggers a mailbox event to the M0 slave core with the address of the shared LED
- state value.
- - Returns the hardware mutex for the shared LED state value.
- There might be a small overlap period where both cores attempt to access the
- hardware mutex. The core attempted to get the mutex will keep trying until the
- mutex is available.
- - At some point, the mailbox will be triggered from the slave core. When this
- happens, a mailbox interrupt is generated and both of the board LED states are
- updated from the shared LED state value.
- - The mailbox interrupt is cleared.
- - The master MCU sleeps while not performing any other tasks.
- What this example does: m0slave_blinky
- - Uses a special version of the startup code that bypasses SystemInit().
- - Does not link agains tthe board library (M4 does board init)
- - Enables the mailbox interrupt.
- - At some point, the mailbox will be triggered from the master core. When this
- happens, a mailbox interrupt is generated. The mailbox contains an addrsss that
- points to the M4's shared LED state value.
- - Grabs the hardware mutex for the shared LED state value.
- - The LED1 state value is toggled in the shared LED state value. This doesn't yet
- toggle board LED1 yet, only the state value.
- - Returns the hardware mutex for the shared LED state value.
- - The mailbox interrupt is cleared.
- - Triggers a mailbox event to the M4 master core that the M0 slave side is done.
- - The slave MCU sleeps while not performing any other tasks.
复制代码
从文字中发现有所谓的hardware mutex算是个好东西,后面再写个帖子分析他还有比较主线的mailbox,这里一句话说明他的作用,一个内置的硬件/软件通道用于两颗封装在一起的U进行通信和交流,挺好的。整体思路就是别把他当双核看,你就会了,分别烧程序应该也不是问题。NXP默认的工具会把生成的两个独立的文件合并之后下载进去,还牵扯一个叫Code Red Technologies Ltd.的公司,有兴趣的可以了解一下。将来相信NXP会开放更多的dual core的细节,当然现在提供的资料完全不影响我们使用它,而且你会用的很好,就是两颗IC,想他们多交流多看mutex和mbox吧,无他。
|
|