其他分享
首页 > 其他分享> > 280045 LIN模块SCI模式 single-buffer mode,收/发-查询模式

280045 LIN模块SCI模式 single-buffer mode,收/发-查询模式

作者:互联网

初始化----------------------------------------------------------------------------------

CpuSysRegs.PCLKCR19.bit.LIN_A = 1;

    // LIN
    Drv_GPIO_SetupPinMux(33, GPIO_MUX_CPU1, 6);//LIN-A RX
    Drv_GPIO_SetupPinOptions(33, GPIO_INPUT, GPIO_ASYNC);

    Drv_GPIO_SetupPinMux(58, GPIO_MUX_CPU1, 9);//LIN-A TX
    Drv_GPIO_SetupPinOptions(58, GPIO_OUTPUT, GPIO_PUSHPULL);

    //
    // Initialize the LIN module
    //
    LIN_initModule(LINA_BASE);

    //
    // Configure the LIN module to operate in SCI mode
    //
    //
    // Enter LIN reset state to perform configurations
    //
    LIN_enterSoftwareReset(LINA_BASE);

    //
    // Switch LIN into SCI mode
    //
    LIN_enableSCIMode(LINA_BASE);

    //
    // Set the SCI communication mode to idle line
    //
    LIN_setSCICommMode(LINA_BASE, LIN_COMM_SCI_IDLELINE);

    //
    // Set SCI to transmit one stop bit
    //
    LIN_setSCIStopBits(LINA_BASE,LIN_SCI_STOP_ONE);

    //
    // Disable parity check
    //
    LIN_disableSCIParity(LINA_BASE);

    //
    // Disable multi-buffer mode
    //
   // LIN_enableMultibufferMode(LINA_BASE);

LIN_disableMultibufferMode(LINA_BASE);

    //
    // Module set to complete operations when halted by debugger
    //
    LIN_setDebugSuspendMode(LINA_BASE, LIN_DEBUG_COMPLETE);

    //
    // Set character length as 8-bits
    //
    LIN_setSCICharLength(LINA_BASE, 8);

    //
    // Set to 4 character in response field
    //
    LIN_setSCIFrameLength(LINA_BASE, 1);

   //禁止内循环测试

LIN_disableIntLoopback(LINA_BASE);
//开启LIN_TX和LIN_RX引脚,不加这句,无法从外部发送和接受数据   

LIN_enableModule(LINA_BASE);

    //
    // Exit LIN reset state
    //
    LIN_exitSoftwareReset(LINA_BASE);

接收-----------------------------------------------------------------------------------------------------

       if(LinaRegs.SCIFLR.bit.RXRDY == 1)
        {
            objSCIDrv.rxData[0]  =  LinaRegs.SCIRD.all;
        }

发送------------------------------------------------------------------------------------------------------

        while(LinaRegs.SCIFLR.bit.TXRDY == 0);
        LinaRegs.SCITD.all = (uint8)0x04;


 

标签:SCI,buffer,LIN,模式,BASE,mode,GPIO,LINA
来源: https://blog.csdn.net/weixin_38914438/article/details/121148196