lpc54102双核介绍及LPC54102寄存器直接编程

2023-03-20  

  随着科技的进步,双核逐渐被淘汰已是时间上的问题,四核乃至八核心CPU也已不再是什么新奇的事物,不过在微控制器领域,双核却是个十分新颖的东西。很多工程师朋友在开发MCU应用系统的时候,若是系统功能复杂、一颗MCU芯片无法满足要求,往往会采用多颗MCU协同工作,把一些“打杂”的工作交给低端的MCU完成,高端的MCU则可以放开“手脚”,完成系统主要的任务。不过这样一来,系统研发的复杂性,成本以及可靠性都会受到不同程度的影响,多微控制器方案带来系统的功耗问题也不容小视。对此,恩智浦推出了基于ARM Cortex-M4和 ARM Cortex-M0+非对称双核架构的LPC54102系列微控制器,旨在提供一个低功耗高性能的双核解决方案,用于超低功耗传感器侦听到数据整合、传感器融合或其他传感器数据处理。


  有幸拿到了搭载LPC54102双核微控制器的LPCXpresso54102开发套件。该套件采用的包装与STM32 Nucleo系列板卡的外包装材料相同,均为透明塑料外壳。这样的包装虽然降低了成本,但在视觉表现上却一点也不逊色于其他包装,透明材料的使用更加凸显出板卡的精致,使得板卡的芯片资源“一丝不挂”地呈现在大家的眼前。

  

  打开包装,取出LPCXpresso54102板卡,板卡整体采用墨蓝色阻焊和乳白色丝印,让人眼前一亮,pcb焊盘的沉金工艺,更是显得高端大气。虽然LPCXpresso54102板卡的设计思路与STM32 Nucleo板卡大致相似,都是板载仿真器加核心板的结构,但相比于Nucleo板卡,LPCXpresso54102明显大了很多,元器件的布局也紧凑了不少。

  

  这块板卡一共有两个micro usb接口,使用普通安卓手机充电数据线便可以和计算机相连接。位于上方的接口是专门给LPC54102供电的接口,给除LINK2仿真器外的部件供电,在不需使用板载调试器时可以连接此接口。心细的话,会发现这个micro usb接口右边还有一个P3接口、是一个两线的排针,分别是5V和GND,此举也是结合了工程师的需求,留出外部电源的接口。下方的USB接口则是LPCLINK2仿真器的接口。说道这里,不得不重点了解一下LPCLINK2仿真器,NXP在这款仿真器的设计上,可谓是不惜成本,主控芯片的选择便显现出霸气,LPC4322双核MCU让LINK2充满了“暴力”!

  

  LPC54102有多个串口,我尝试用寄存器直接操作!经过多次测试,可以发送和接收数据!内部晶振12MHz,没有锁频,波特率9600b/s,使用第一个串口!也可以把其它串口都用上。


  参考代码:

  unsigned long buf;

  #define DELAY_COUNT 0xFFFF

  void Delay( long int Count)

  {

  for(; Count!= 0;Count--);

  }

  main()

  {

  *(long*)0x400000c0=0xe10b;///使能P0口

  *(long*)0x1c002000=0xf0000002;

  *(long*)0x4001C004=0x191;///p01为串口

  *(long*)0x4001C000=0x191;;///p00为串口

  *(long*)0x40000020=0x1;

  *(long*)0x40080010=0x8002;///

  *(long*)0x40084000=0x4;

  *(long*)0x40084020=78;///9600b/s

  *(long*)0x40084000|=0x1;

  ///printf(“hello world!”);

  asm(“nop”);

  *(long*)0x4008401c=‘L’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘P’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘C’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘5’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘4’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘1’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘0’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘2’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=0xd;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=0xa;///buf;

  while(!(*(long*)0x40084008&0x04));

  while(1)

  {

  *(long*)0x4008401c=‘L’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘P’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘C’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘5’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘4’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘1’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘0’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=‘2’;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=0xd;///buf;

  while(!(*(long*)0x40084008&0x04));

  *(long*)0x4008401c=0xa;///buf;

  while(!(*(long*)0x40084008&0x04));

  Delay(DELAY_COUNT);

  Delay(DELAY_COUNT);

  Delay(DELAY_COUNT);

  }

  }

  ///下边是老外的头文件定义

  /* Main memory addresses */

  #define LPC_FLASHMEM_BASE 0x00000000UL

  #define LPC_SRAM0_BASE 0x02000000UL

  #define LPC_SRAM1_BASE 0x02010000UL

  #define LPC_ROM_BASE 0x03000000UL

  #define LPC_SRAM2_BASE 0x03400000UL

  #define LPC_GPIO_PORT_BASE 0x1C000000UL

  #define LPC_DMA_BASE 0x1C004000UL

  #define LPC_CRC_BASE 0x1C010000UL

  #define LPC_SCT_BASE 0x1C018000UL

  #define LPC_MBOX_BASE 0x1C02C000UL

  #define LPC_ADC_BASE 0x1C034000UL

  #define LPC_FIFO_BASE 0x1C038000UL

  /* APB0 peripheral group addresses */

  #define LPC_SYSCON_BASE 0x40000000UL

  #define LPC_TIMER2_BASE 0x40004000UL

  #define LPC_TIMER3_BASE 0x40008000UL

  #define LPC_TIMER4_BASE 0x4000C000UL

  #define LPC_GPIO_GROUPINT0_BASE 0x40010000UL

  #define LPC_GPIO_GROUPINT1_BASE 0x40014000UL

  #define LPC_PIN_INT_BASE 0x40018000UL

  #define LPC_IOCON_BASE 0x4001C000UL

  #define LPC_UTICK_BASE 0x40020000UL

  #define LPC_FMC_BASE 0x40024000UL

  #define LPC_PMU_BASE 0x4002C000UL

  #define LPC_WWDT_BASE 0x40038000UL

  #define LPC_RTC_BASE 0x4003C000UL

  /* APB1 peripheral group addresses */

  #define LPC_ASYNC_SYSCON_BASE 0x40080000UL

  #define LPC_USART0_BASE 0x40084000UL

  #define LPC_USART1_BASE 0x40088000UL

  #define LPC_USART2_BASE 0x4008C000UL

  #define LPC_USART3_BASE 0x40090000UL

  #define LPC_I2C0_BASE 0x40094000UL

  #define LPC_I2C1_BASE 0x40098000UL

  #define LPC_I2C2_BASE 0x4009C000UL

  #define LPC_SPI0_BASE 0x400A4000UL

  #define LPC_SPI1_BASE 0x400A8000UL

  #define LPC_TIMER0_BASE 0x400B4000UL

  #define LPC_TIMER1_BASE 0x400B8000UL

  #define LPC_INMUX_BASE 0x40050000UL

  #define LPC_RITIMER_BASE 0x40070000UL

  #define LPC_MRT_BASE 0x40074000UL

  /* Main memory register access */

  #define LPC_GPIO ((LPC_GPIO_T *) LPC_GPIO_PORT_BASE)

  #define LPC_DMA ((LPC_DMA_T *) LPC_DMA_BASE)

  #define LPC_CRC ((LPC_CRC_T *) LPC_CRC_BASE)

  #define LPC_SCT ((LPC_SCT_T *) LPC_SCT_BASE)

  #define LPC_MBOX ((LPC_MBOX_T *) LPC_MBOX_BASE)

  #define LPC_ADC ((LPC_ADC_T *) LPC_ADC_BASE)

  #define LPC_FIFO ((LPC_FIFO_T *) LPC_FIFO_BASE)

  /* APB0 peripheral group register access */

  #define LPC_SYSCON ((LPC_SYSCON_T *) LPC_SYSCON_BASE)

  #define LPC_TIMER2 ((LPC_TIMER_T *) LPC_TIMER2_BASE)

  #define LPC_TIMER3 ((LPC_TIMER_T *) LPC_TIMER3_BASE)

  #define LPC_TIMER4 ((LPC_TIMER_T *) LPC_TIMER4_BASE)

  #define LPC_GINT ((LPC_GPIOGROUPINT_T *) LPC_GPIO_GROUPINT0_BASE)

  #define LPC_PININT ((LPC_PIN_INT_T *) LPC_PIN_INT_BASE)

  #define LPC_IOCON ((LPC_IOCON_T *) LPC_IOCON_BASE)

  #define LPC_UTICK ((LPC_UTICK_T *) LPC_UTICK_BASE)

  #define LPC_WWDT ((LPC_WWDT_T *) LPC_WWDT_BASE)

  #define LPC_RTC ((LPC_RTC_T *) LPC_RTC_BASE)

  /* APB1 peripheral group register access */

  #define LPC_ASYNC_SYSCON ((LPC_ASYNC_SYSCON_T *) LPC_ASYNC_SYSCON_BASE)

  #define LPC_USART0 ((LPC_USART_T *) LPC_USART0_BASE)

  #define LPC_USART1 ((LPC_USART_T *) LPC_USART1_BASE)

  #define LPC_USART2 ((LPC_USART_T *) LPC_USART2_BASE)

  #define LPC_USART3 ((LPC_USART_T *) LPC_USART3_BASE)

  #define LPC_I2C0 ((LPC_I2C_T *) LPC_I2C0_BASE)

  #define LPC_I2C1 ((LPC_I2C_T *) LPC_I2C1_BASE)

  #define LPC_I2C2 ((LPC_I2C_T *) LPC_I2C2_BASE)

  #define LPC_SCT0 LPC_SCT

  #define LPC_SPI0 ((LPC_SPI_T *) LPC_SPI0_BASE)

  #define LPC_SPI1 ((LPC_SPI_T *) LPC_SPI1_BASE)

  #define LPC_TIMER0 ((LPC_TIMER_T *) LPC_TIMER0_BASE)

  #define LPC_TIMER1 ((LPC_TIMER_T *) LPC_TIMER1_BASE)

  #define LPC_INMUX ((LPC_INMUX_T *) LPC_INMUX_BASE)

  #define LPC_RITIMER ((LPC_RITIMER_T *) LPC_RITIMER_BASE)

  #define LPC_MRT ((LPC_MRT_T *) LPC_MRT_BASE)

  #define LPC_PMU ((LPC_PMU_T *) LPC_PMU_BASE)

  由于LPC54102支持单电源1.62v~3.6v供电,为了保护MCU接口安全,在板子的设计上可以看到大量的双电源转换收发器。


文章来源于:电子工程世界    原文链接
本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。