查看: 2142|回复: 1

[原创] 【LPC54114双核任务一】①资料 上电 点灯

[复制链接]
  • TA的每日心情
    擦汗
    2017-12-29 14:09
  • 签到天数: 144 天

    [LV.7]常住居民III

    9

    主题

    534

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    1607
    最后登录
    2019-3-18
    发表于 2017-6-22 00:19:23 | 显示全部楼层 |阅读模式
    本帖最后由 liao122 于 2017-6-22 21:46 编辑

    首先第一件事当然是收集资料
        1、官网(http://mcuxpresso.nxp.com/en/welcome)下载了SDK,有IAR,keil 的,我以上传至百度网盘,有需要的可下载
        2、万利网站提供的资料 (百度网盘)
        3、keil 54000 系列 pack (百度网盘)

    网盘.png
    百度网盘链接:     https://pan.baidu.com/s/1nvODEqP


    PS: 发现用联通的4G卡上官网速度杆杆的,能500K/s的下载速度。
            我发现固件不更新虚拟串口也能输出。

    然后上电测试
          插上USB连上电脑(板子CN1口),出现的是板子预装的演示程序,按按键led9会亮,有声音事led8会亮,串口输出检测的温度

    开箱照
    开箱.png


    上电的板子
    上电.png

    串口输出
    串口温度输出.png


    点灯

    1、没有安装LPC 54000 pack 安装包的需先安装 (以上传至百度网盘)



    2、打开下载的SDK的 led例程,路径如图
    LED例程1.png


    3、查看LPC54114板子led IO口
    在万利提供的资料有PDF的原理图
    LED例程2.png
    例程3.png


    4、按照原理中的IO修改例程

    BOARD_InitPins(); 函数配置led0~led7 IO
    1. /*FUNCTION**********************************************************************
    2. *
    3. * Function Name : BOARD_InitPins
    4. * Description   : Configures pin routing and optionally pin electrical features.
    5. *
    6. *END**************************************************************************/
    7. void BOARD_InitPins(void) { /* Function assigned for the Core #0 (ARM Cortex-M4) */
    8.   CLOCK_EnableClock(kCLOCK_Iocon);                           /* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */

    9.   const uint32_t port0_pin0_config = (
    10.     IOCON_PIO_FUNC1 |                                        /* Pin is configured as FC0_RXD_SDA_MOSI */
    11.     IOCON_PIO_MODE_INACT |                                   /* No addition pin function */
    12.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    13.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    14.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    15.     IOCON_PIO_SLEW_STANDARD |                                /* Standard mode, output slew rate control is enabled */
    16.     IOCON_PIO_OPENDRAIN_DI                                   /* Open drain is disabled */
    17.   );
    18.   IOCON_PinMuxSet(IOCON, PORT0_IDX, PIN0_IDX, port0_pin0_config); /* PORT0 PIN0 (coords: 31) is configured as FC0_RXD_SDA_MOSI */
    19.   const uint32_t port0_pin1_config = (
    20.     IOCON_PIO_FUNC1 |                                        /* Pin is configured as FC0_TXD_SCL_MISO */
    21.     IOCON_PIO_MODE_INACT |                                   /* No addition pin function */
    22.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    23.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    24.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    25.     IOCON_PIO_SLEW_STANDARD |                                /* Standard mode, output slew rate control is enabled */
    26.     IOCON_PIO_OPENDRAIN_DI                                   /* Open drain is disabled */
    27.   );
    28.   IOCON_PinMuxSet(IOCON, PORT0_IDX, PIN1_IDX, port0_pin1_config); /* PORT0 PIN1 (coords: 32) is configured as FC0_TXD_SCL_MISO */
    29.         
    30.         
    31. /****************************************************************************/
    32. // LED configured        
    33. const uint32_t port0_pin15_config = (
    34.     IOCON_PIO_FUNC0 |                                        /* Pin is configured as PIO0_15 */
    35.     IOCON_PIO_I2CSLEW_GPIO |                                 /* GPIO mode */
    36.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    37.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    38.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    39.     IOCON_PIO_I2CDRIVE_LOW |                                 /* Low drive: 4 mA */
    40.     IOCON_PIO_I2CFILTER_EN                                   /* I2C 50 ns glitch filter enabled */
    41.   );
    42.   IOCON_PinMuxSet(IOCON, 0, 15, port0_pin15_config); /* PORT0 PIN15 (LED1) is configured as PIO0_15 */


    43. const uint32_t port0_pin19_config = (
    44.     IOCON_PIO_FUNC0 |                                        /* Pin is configured as PIO0_19 */
    45.     IOCON_PIO_I2CSLEW_GPIO |                                 /* GPIO mode */
    46.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    47.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    48.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    49.     IOCON_PIO_I2CDRIVE_LOW |                                 /* Low drive: 4 mA */
    50.     IOCON_PIO_I2CFILTER_EN                                   /* I2C 50 ns glitch filter enabled */
    51.   );
    52.   IOCON_PinMuxSet(IOCON, 0, 19, port0_pin19_config); /* PORT0 PIN19 (LED2) is configured as PIO0_19 */


    53. const uint32_t port0_pin22_config = (
    54.     IOCON_PIO_FUNC0 |                                        /* Pin is configured as PIO0_22 */
    55.     IOCON_PIO_I2CSLEW_GPIO |                                 /* GPIO mode */
    56.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    57.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    58.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    59.     IOCON_PIO_I2CDRIVE_LOW |                                 /* Low drive: 4 mA */
    60.     IOCON_PIO_I2CFILTER_EN                                   /* I2C 50 ns glitch filter enabled */
    61.   );
    62.   IOCON_PinMuxSet(IOCON, 0, 22, port0_pin22_config); /* PORT0 PIN22 (LED3) is configured as PIO0_22 */


    63. const uint32_t port0_pin25_config = (
    64.     IOCON_PIO_FUNC0 |                                        /* Pin is configured as PIO0_25 */
    65.     IOCON_PIO_I2CSLEW_GPIO |                                 /* GPIO mode */
    66.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    67.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    68.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    69.     IOCON_PIO_I2CDRIVE_LOW |                                 /* Low drive: 4 mA */
    70.     IOCON_PIO_I2CFILTER_EN                                   /* I2C 50 ns glitch filter enabled */
    71.   );
    72.   IOCON_PinMuxSet(IOCON, 0, 25, port0_pin25_config); /* PORT0 PIN25 (LED4) is configured as PIO0_25 */


    73. const uint32_t port0_pin26_config = (
    74.     IOCON_PIO_FUNC0 |                                        /* Pin is configured as PIO0_26 */
    75.     IOCON_PIO_I2CSLEW_GPIO |                                 /* GPIO mode */
    76.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    77.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    78.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    79.     IOCON_PIO_I2CDRIVE_LOW |                                 /* Low drive: 4 mA */
    80.     IOCON_PIO_I2CFILTER_EN                                   /* I2C 50 ns glitch filter enabled */
    81.   );
    82.   IOCON_PinMuxSet(IOCON, 0, 26, port0_pin26_config); /* PORT0 PIN26 (LED5) is configured as PIO0_26 */


    83. const uint32_t port0_pin29_config = (
    84.     IOCON_PIO_FUNC0 |                                        /* Pin is configured as PIO0_29 */
    85.     IOCON_PIO_I2CSLEW_GPIO |                                 /* GPIO mode */
    86.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    87.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    88.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    89.     IOCON_PIO_I2CDRIVE_LOW |                                 /* Low drive: 4 mA */
    90.     IOCON_PIO_I2CFILTER_EN                                   /* I2C 50 ns glitch filter enabled */
    91.   );
    92.   IOCON_PinMuxSet(IOCON, 0, 29, port0_pin29_config); /* PORT0 PIN29 (LED6) is configured as PIO0_29 */



    93. const uint32_t port0_pin30_config = (
    94.     IOCON_PIO_FUNC0 |                                        /* Pin is configured as PIO0_30 */
    95.     IOCON_PIO_I2CSLEW_GPIO |                                 /* GPIO mode */
    96.     IOCON_PIO_INV_DI |                                       /* Input function is not inverted */
    97.     IOCON_PIO_DIGITAL_EN |                                   /* Enables digital function */
    98.     IOCON_PIO_INPFILT_OFF |                                  /* Input filter disabled */
    99.     IOCON_PIO_I2CDRIVE_LOW |                                 /* Low drive: 4 mA */
    100.     IOCON_PIO_I2CFILTER_EN                                   /* I2C 50 ns glitch filter enabled */
    101.   );
    102.   IOCON_PinMuxSet(IOCON, 0, 30, port0_pin30_config); /* PORT0 PIN30 (LED7) is configured as PIO0_30 */

    复制代码

    主函数如下
    1. void Led(uint32_t port, uint32_t pin, uint32_t output)
    2. {
    3.         gpio_pin_config_t led_config = {
    4.         kGPIO_DigitalOutput, 0,
    5.     };
    6.         GPIO_PinInit(GPIO, port, pin, &led_config);  //IO¿ÚÅäÖÃÊä³ö
    7.   GPIO_WritePinOutput(GPIO, port, pin, output);               
    8. }

    9. int main(void)
    10. {
    11.     uint32_t port_state = 0;

    12.     /* Define the init structure for the output LED pin*/
    13.     gpio_pin_config_t led_config = {
    14.         kGPIO_DigitalOutput, 0,
    15.     };

    16.     /* Board pin, clock, debug console init */
    17.     /* attach 12 MHz clock to FLEXCOMM0 (debug console) */
    18.     CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
    19.     /* enable clock for GPIO*/
    20.     CLOCK_EnableClock(kCLOCK_Gpio0);
    21.     CLOCK_EnableClock(kCLOCK_Gpio1);

    22.     BOARD_InitPins();
    23.     BOARD_BootClockFROHF48M();
    24.     BOARD_InitDebugConsole();

    25.     /* Print a note to terminal. */
    26.     PRINTF("\r\n GPIO Driver example\r\n");
    27.     PRINTF("\r\n The LED is taking turns to shine.\r\n");

    28.     /* Init output LED GPIO. */
    29.                
    30.                 Led(0,15,1);//led0~led3 ¸ßµçƽµãÁÁ
    31.                 Led(0,19,1);
    32.                 Led(0,21,1);
    33.                 Led(0,22,1);
    34.                 Led(0,25,0);//led4~led7 µÍµçƽµãÁÁ
    35.                 Led(0,26,0);
    36.                 Led(0,29,0);
    37.                 Led(0,30,0);

    38.     while (1)
    39.     {
    40.                                         ;
    41.     }
    42. }
    复制代码


    下载程序,效果如图
    点灯.png













    签到!!!
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    2017-12-29 14:09
  • 签到天数: 144 天

    [LV.7]常住居民III

    9

    主题

    534

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    1607
    最后登录
    2019-3-18
     楼主| 发表于 2017-6-22 23:24:48 | 显示全部楼层
    资料已上传
    签到!!!
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /4 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2024-5-6 23:52 , Processed in 0.114730 second(s), 21 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表