找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 8896|回复: 9
打印 上一主题 下一主题
收起左侧

S32K144_Uart串口源程序

  [复制链接]
跳转到指定楼层
楼主
S32K144 自身NorFlash读写,在NXP官方编译器S32 Design Studio for ARM Version 2018.R1(需要打补丁跟新到 RTM2.0版SDK)直接编译。该串口代码与官方库不冲突,可继续使用官方提供的便利工具,IO和Uart模块的可视化配置,并且实现Uart方便的中断接受,不丢失。从FIFO中直接提取数据,改善官方SDK库效读取率低,操作不方便等问题。


单片机源程序如下:
  1. /* ###################################################################
  2. **     Filename    : main.c
  3. **     Processor   : S32K14x
  4. **     Abstract    :
  5. **         Main module.
  6. **         This module contains user's application code.
  7. **     Settings    :
  8. **     Contents    :
  9. **         No public methods
  10. **
  11. ** ###################################################################*/

  12. /* MODULE main */


  13. /* Including necessary module. Cpu.h contains other modules needed for compiling.*/
  14. #include "Cpu.h"

  15. /* User includes (#include below this line is not maintained by Processor Expert) */

  16. #include "common.h"

  17. /*!
  18.   \brief The main function for the project.
  19.   \details The startup initialization sequence is the following:
  20. */

  21. int main(void)
  22. {
  23.   /* Write your local variable definition here */

  24.   /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  25.   #ifdef PEX_RTOS_INIT
  26.     PEX_RTOS_INIT();                   /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
  27.   #endif
  28.   /*** End of Processor Expert internal initialization.                    ***/

  29.         BoardInit();

  30.         UART_Text();

  31.         while(1){

  32.                 OSIF_TimeDelay(1000);
  33.         };

  34.         return 0;
  35. }
  36. /* END main */
复制代码

所有资料51hei提供下载:
HTKJ_App.7z (388.95 KB, 下载次数: 98)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶1 踩
回复

使用道具 举报

沙发
ID:145007 发表于 2019-3-15 10:46 | 只看该作者
您好,请问为什么我用你的程序while循环里面单独处理串口读写的没问题,但是我加了can那些模块进去,在while循环里面也一起处理can数据,然后串口就一直读不到数据了,我定时发数据过去,但是打印出来读到的数据一直为0
回复

使用道具 举报

板凳
ID:606820 发表于 2019-9-3 11:45 | 只看该作者
我的S32K串口一直不稳定,好难,还没有头绪
回复

使用道具 举报

地板
ID:229982 发表于 2020-1-2 16:04 | 只看该作者
谢谢楼主分享!
回复

使用道具 举报

5#
ID:712223 发表于 2020-3-20 14:52 | 只看该作者
谢谢楼主分享
回复

使用道具 举报

6#
ID:766535 发表于 2020-6-1 14:49 | 只看该作者
static void rxCallback(void *driverState, uart_event_t event, void *userData)
{
    /* Unused parameters */
    (void)driverState;
    (void)userData;

        switch(event)
        {
                case UART_EVENT_RX_FULL:
                        if(uart_rx_handle.uart_rx_tail<UART_RX_SIZE-1)
                        {
                                uart_rx_handle.uart_rx_tail++;
                                LPUART_DRV_SetRxBuffer(INST_LPUART1, &uart_rx_handle.uart_rxbuff[(uart_rx_handle.uart_rx_tail)%UART_RX_SIZE], 1U);
                        }
                        else
                        {
                                uart_rx_handle.uart_rx_tail = 0;
                        }
                        rx_full_cnt++;
                        break;
                case UART_EVENT_ERROR:
                        error_cnt++;
                        break;
                case UART_EVENT_END_TRANSFER:
                        end_cnt++;
                        break;
                default:

                        break;
        }

        /* Update the buffer index and the rx buffer */
        LPUART_DRV_ReceiveData(INST_LPUART1, &uart_rx_handle.uart_rxbuff[uart_rx_handle.uart_rx_tail%UART_RX_SIZE], 1U);
}


这中断回调函数中这样接收,为何发快了会产生错误?
回复

使用道具 举报

7#
ID:766535 发表于 2020-6-1 14:52 | 只看该作者
需要下载一个程序看看,谢谢
回复

使用道具 举报

8#
ID:578078 发表于 2020-7-23 17:43 | 只看该作者
这个FIFO跟硬件说的没关系吧。S32K说有4个字的FIFO模式怎么做?
回复

使用道具 举报

9#
ID:829212 发表于 2020-10-13 11:30 | 只看该作者
感谢分享 使用的是LPUART还是SDK的接口呢?
回复

使用道具 举报

10#
ID:484960 发表于 2021-2-18 08:59 | 只看该作者
楼主你好,我想问一下我现在用的最新版本的S32DS,为什么我在外面写的一个Delay函数往主函数里面调不进去尼,我直接把双层for作为延时就可以用封装成一个函数直接往主函数里面调程序就卡在双层for那里就不走了。这是什么鬼,是官方的BUg还是一个其他什么问题。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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