標題: S32K144_Uart串口源程序 [打印本頁]

作者: GXLife    時間: 2019-1-3 12:46
標題: S32K144_Uart串口源程序
S32K144 自身NorFlash讀寫,在NXP官方編譯器S32 Design Studio for ARM Version 2018.R1(需要打補丁跟新到 RTM2.0版SDK)直接編譯。該串口代碼與官方庫不沖突,可繼續(xù)使用官方提供的便利工具,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)



作者: 夢逸    時間: 2019-3-15 10:46
您好,請問為什么我用你的程序while循環(huán)里面單獨處理串口讀寫的沒問題,但是我加了can那些模塊進去,在while循環(huán)里面也一起處理can數據,然后串口就一直讀不到數據了,我定時發(fā)數據過去,但是打印出來讀到的數據一直為0
作者: tianbianren123    時間: 2019-9-3 11:45
我的S32K串口一直不穩(wěn)定,好難,還沒有頭緒
作者: libinhithd    時間: 2020-1-2 16:04
謝謝樓主分享!
作者: 814704163    時間: 2020-3-20 14:52
謝謝樓主分享
作者: leiyijing2003    時間: 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);
}


這中斷回調函數中這樣接收,為何發(fā)快了會產生錯誤?
作者: leiyijing2003    時間: 2020-6-1 14:52
需要下載一個程序看看,謝謝
作者: ccd007    時間: 2020-7-23 17:43
這個FIFO跟硬件說的沒關系吧。S32K說有4個字的FIFO模式怎么做?
作者: lj861212    時間: 2020-10-13 11:30
感謝分享 使用的是LPUART還是SDK的接口呢?
作者: xddfandy    時間: 2021-2-18 08:59
樓主你好,我想問一下我現在用的最新版本的S32DS,為什么我在外面寫的一個Delay函數往主函數里面調不進去尼,我直接把雙層for作為延時就可以用封裝成一個函數直接往主函數里面調程序就卡在雙層for那里就不走了。這是什么鬼,是官方的BUg還是一個其他什么問題。




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1