查看: 2126|回复: 2

[已解决] IAR_SDK2.0_MKL16Z128 Uart0直接使用SDK驱动出错

[复制链接]
  • TA的每日心情

    2016-11-8 14:02
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    10

    主题

    31

    帖子

    0

    注册会员

    Rank: 2

    积分
    172
    最后登录
    1970-1-1
    发表于 2017-3-17 15:10:35 | 显示全部楼层 |阅读模式
    MKL16Z128处理器,UART0和UART1/2的配置寄存器有差异

    /** UART0 - Register Layout Typedef */
    typedef struct {
      __IO uint8_t BDH;                                /**< UART Baud Rate Register High, offset: 0x0 */
      __IO uint8_t BDL;                                /**< UART Baud Rate Register Low, offset: 0x1 */
      __IO uint8_t C1;                                 /**< UART Control Register 1, offset: 0x2 */
      __IO uint8_t C2;                                 /**< UART Control Register 2, offset: 0x3 */
      __IO uint8_t S1;                                 /**< UART Status Register 1, offset: 0x4 */
      __IO uint8_t S2;                                 /**< UART Status Register 2, offset: 0x5 */
      __IO uint8_t C3;                                 /**< UART Control Register 3, offset: 0x6 */
      __IO uint8_t D;                                  /**< UART Data Register, offset: 0x7 */
      __IO uint8_t MA1;                                /**< UART Match Address Registers 1, offset: 0x8 */
      __IO uint8_t MA2;                                /**< UART Match Address Registers 2, offset: 0x9 */
      __IO uint8_t C4;                                 /**< UART Control Register 4, offset: 0xA */
      __IO uint8_t C5;                                 /**< UART Control Register 5, offset: 0xB */
    } UART0_Type;


    /** UART1/2 - Register Layout Typedef */
    typedef struct {
      __IO uint8_t BDH;                                /**< UART Baud Rate Register: High, offset: 0x0 */
      __IO uint8_t BDL;                                /**< UART Baud Rate Register: Low, offset: 0x1 */
      __IO uint8_t C1;                                 /**< UART Control Register 1, offset: 0x2 */
      __IO uint8_t C2;                                 /**< UART Control Register 2, offset: 0x3 */
      __I  uint8_t S1;                                 /**< UART Status Register 1, offset: 0x4 */
      __IO uint8_t S2;                                 /**< UART Status Register 2, offset: 0x5 */
      __IO uint8_t C3;                                 /**< UART Control Register 3, offset: 0x6 */
      __IO uint8_t D;                                  /**< UART Data Register, offset: 0x7 */
      __IO uint8_t C4;                                 /**< UART Control Register 4, offset: 0x8 */
    } UART_Type;


    SDK的驱动都使用UART_Type,例程Uart1,而实际使用Uart0时,若调用标准驱动,导致程序错误~


    如何解决? 自己写驱动?

    最佳答案

    UART0的不要使用fsl_uart.h中的库,而要使用fsl_lpsci.h中的库,两者是不太一样的
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2018-7-23 21:04
  • 签到天数: 103 天

    连续签到: 1 天

    [LV.6]常住居民II

    228

    主题

    5379

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    16697
    最后登录
    1970-1-1
    发表于 2017-3-17 16:13:38 | 显示全部楼层
    UART0的不要使用fsl_uart.h中的库,而要使用fsl_lpsci.h中的库,两者是不太一样的
    回复 支持 1 反对 0

    使用道具 举报

  • TA的每日心情

    2016-11-8 14:02
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    10

    主题

    31

    帖子

    0

    注册会员

    Rank: 2

    积分
    172
    最后登录
    1970-1-1
     楼主| 发表于 2017-3-17 16:40:55 | 显示全部楼层
    lkl0305 发表于 2017-3-17 16:13
    UART0的不要使用fsl_uart.h中的库,而要使用fsl_lpsci.h中的库,两者是不太一样的 ...

    非常感谢~
    我来试试
    回复 支持 反对

    使用道具 举报

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

    本版积分规则

    关闭

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

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

    GMT+8, 2025-7-19 09:03 , Processed in 0.091139 second(s), 25 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

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