查看: 1917|回复: 0

[原创] MCX先手尝鲜--9.新建RTE工程

[复制链接]
  • TA的每日心情
    慵懒
    2025-5-7 08:45
  • 签到天数: 279 天

    连续签到: 1 天

    [LV.8]以坛为家I

    114

    主题

    1313

    帖子

    29

    版主

    Rank: 7Rank: 7Rank: 7

    积分
    10946

    热心会员

    最后登录
    2025-7-25
    发表于 2024-1-21 11:19:54 | 显示全部楼层 |阅读模式
    本帖最后由 az158 于 2024-1-21 11:19 编辑

    行走单片机届,怎么能避开keil的RTE开发,今天咱们就来耍一耍。

    新建工程,选择芯片
    微信截图_20240121110635.png

    配置RTE文件,按下图配置就行
    微信截图_20240121110728.png
    微信截图_20240121110751.png
    微信截图_20240121110800.png
    微信截图_20240121110808.png
    微信截图_20240121110821.png
    微信截图_20240121110814.png
    微信截图_20240121110829.png

    配置工程
    微信截图_20240121111154.png
    1. NDEBUG, CPU_MCXN947VDF_cm33_core0, MCUXPRESSO_SDK
    复制代码

    1. -fno-common -fdata-sections -ffreestanding -fno-builtin -mthumb
    复制代码


    微信截图_20240121111201.png
    1. CPU_LPC55S69JBD100_cm33_core0, NDEBUG, KEIL, NDEBUG
    复制代码


    微信截图_20240121111208.png

    1. --remove --entry=Reset_Handler
    2. --remove
    复制代码

    修改pin_mux.c文件,加入初始化IO代码(正式开发这里使用MCUXpresso Config Tools配置比较爽)
    1. CLOCK_EnableClock(kCLOCK_Port3);

    2. const port_pin_config_t port3_4_pinF14_config = {/* Internal pull-up/down resistor is disabled */
    3.                                                  kPORT_PullDisable,
    4.                                                  /* Low internal pull resistor value is selected. */
    5.                                                  kPORT_LowPullResistor,
    6.                                                  /* Fast slew rate is configured */
    7.                                                  kPORT_FastSlewRate,
    8.                                                  /* Passive input filter is disabled */
    9.                                                  kPORT_PassiveFilterDisable,
    10.                                                  /* Open drain output is disabled */
    11.                                                  kPORT_OpenDrainDisable,
    12.                                                  /* Low drive strength is configured */
    13.                                                  kPORT_LowDriveStrength,
    14.                                                  /* Pin is configured as PIO3_4 */
    15.                                                  kPORT_MuxAlt0,
    16.                                                  /* Digital input enabled */
    17.                                                  kPORT_InputBufferEnable,
    18.                                                  /* Digital input is not inverted */
    19.                                                  kPORT_InputNormal,
    20.                                                  /* Pin Control Register fields [15:0] are not locked */
    21.                                                  kPORT_UnlockRegister};
    22. /* PORT3_4 (pin F14) is configured as PIO3_4 */
    23. PORT_SetPinConfig(PORT3, 4U, &port3_4_pinF14_config);
    复制代码

    新建并添加main.c文件
    1. #include "fsl_device_registers.h"
    2. #include "pin_mux.h"
    3. #include "board.h"

    4. #include "fsl_common.h"

    5. /*******************************************************************************
    6. * Variables
    7. ******************************************************************************/
    8. volatile uint32_t g_systickCounter;

    9. /*******************************************************************************
    10. * Code
    11. ******************************************************************************/
    12. void SysTick_Handler(void)
    13. {
    14.     if (g_systickCounter != 0U)
    15.     {
    16.         g_systickCounter--;
    17.     }
    18. }

    19. void SysTick_DelayTicks(uint32_t n)
    20. {
    21.     g_systickCounter = n;
    22.     while (g_systickCounter != 0U)
    23.     {
    24.     }
    25. }

    26. int main(void)
    27. {
    28.     BOARD_InitPins();
    29.     BOARD_InitBootClocks();

    30.     CLOCK_EnableClock(kCLOCK_Gpio3);
    31.     LED_RED_INIT(LOGIC_LED_OFF);
    32.    
    33.     if (SysTick_Config(SystemCoreClock / 1000U))
    34.     {
    35.         while (1)
    36.         {
    37.         }
    38.     }

    39.     while (1)
    40.     {
    41.         SysTick_DelayTicks(1000U);
    42.         GPIO_PortToggle(BOARD_LED_RED_GPIO, 1u << BOARD_LED_RED_GPIO_PIN);
    43.     }
    44. }
    复制代码

    整体工程如下
    微信截图_20240121111800.png

    编译下载看看


    小灯正常闪烁。



    该会员没有填写今日想说内容.
    回复

    使用道具 举报

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

    本版积分规则

    关闭

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

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

    GMT+8, 2025-7-27 12:28 , Processed in 0.078711 second(s), 20 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

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