无线电爱好网

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

S32K144_PKE HT-3 Configuration

2023-2-16 10:38| 发布者: 闪电| 查看: 18| 评论: 0

摘要: 一、流程及运作结果流程介绍PKE HT-3 配置流程(其中细节部分并没有全部展示)如图1.1所示。图 1.1 PKE HT-3 配置流程图运作结果图1.2是 PKE HT-3 认证时整体硬件环境搭建的截图,高频接收使用的是 NCK2912,基站板 ...


三、 参考资料

  • Um525831 – NJJ29C2 Objective User Manual (Rev. 3.1, 19 June 2020)
  • UM – SCA1903 – NJJ29C2 Customer Demo Operation (Rev. 3.0, 8 May 2020)
  • NJJ29C2 Explanations about initializations of application examples (Rev. 1.0, 15 July 2020)

 

四、 附录
  1. LPSPI 初始化配置及数据发送代码

通过将 LPSPI TCR 寄存器的 CONT 写 1,可以保证 SCSN 在命令传输过程中保持低电平(连续传输),在发送结束后再次对 TCR 进行写入,可以使 SCSN 重新拉高。注意,TCR 寄存器需要将 32-bit 数据一次性写入。具体 LPSPI 初始化代码如下:

LPSPI.c

void LPSPI0_Init_Master(void)

{

    /* disable the LPSPI0 clock(clear first,then set parameters such as PCS etc) */

    DISABLE_PORT_CLOCK(PCC_LPSPI0_INDEX);

 

    /* PCC LPSPI0 Register configuration:

     * Field               Descriptions

     * [31] PR             1b - Peripheral is present.

     * [30] CGC            1b - Clock enabled.Lock the clock selection.(can't change)

     * [26:24] PCS         110b - clock option 6(SPLLDIV2_CLK:40MHz)

     */

    PCC->PCCn[PCC_LPSPI0_INDEX] |= PCC_PCCn_PR(0b1)

                                | PCC_PCCn_CGC(0b1)

                                | PCC_PCCn_PCS(0b110);

 

    /* Disable LPSPI0 Module Configuration:

     * Field               Descriptions

     * [9] RRF             0b - Receive FIFO not reset

     * [8] RTF             0b - Transmit FIFO not reset

     * [3] DBGEN           0b - LPSPI module is disabled in debug mode

     * [2] DOZEN           0b - LPSPI module is enabled in Doze mode

     * [1] RST             0b - Module is not reset

     * [0] MEN             0b - Module is disabled

     */

    LPSPI0->CR = 0x00000000;

 

    /* Interrupt :

     * Field               Descriptions

     * [1] RDIE            1b - Receive Data Interrupt Enable

     *  */

    LPSPI0->IER |= LPSPI_IER_RDIE_MASK;

 

    /* DMA request is disabled */

    LPSPI0->DER = 0x00000000;

 

    /* Configuration Register 0 setup:

     * Field               Descriptions

     * [9] RDMO            0b - Received data is stored in the receive FIFO as in normal operations

     * [8] CIRFIFO         0b - Circular FIFO is disabled

     * [0] HREN            0b - Host request is disabled

     * */

    LPSPI0->CFGR0 = 0x00000000;

 

    /* Configuration Register 1 setup:

     * Field               Descriptions

     * [27] PCSCFG         0b - PCS[3:2] are enabled

     * [26] OUTCFG         0b - Output data retains last value(not tri-state) when CS is negated

     * [25:24] PINCFG      00b - SIN is used for input data and SOUT is used for output data

     * [18:16] MATCFG      000b - Match is disabled

     * [11:8] PCSPOL       0000b - PCSx is active low

     * [3] NOSTALL         1b - Transfers will not stall when the transmit FIFO is empty or the receive FIFO is full

     * [2] AUTOPCS         0b - Automatic PCS generation is disabled

     * [1] SAMPLE          0b - Input data is sampled on SCK edge

     * [0] MASTER          1b - Master Mode

     */

    LPSPI0->CFGR1 |= LPSPI_CFGR1_NOSTALL(0b1) | LPSPI_CFGR1_MASTER(0b1);

 

    /* Transmit Command Register Configuration(only be written using 32-bit writes):

     * Field               Description

     * [31] CPOL           0b - The inactive state value of SCK is low

     * [30] CPHA           1b - Data is changed on the leading edge of SCK and captured on the following edge of SCK

     * [29:27] Prescale    010b - Functional clock devided by 2^2 = 4

     * [25:24] PCS         00b - Transfer using LPSPI_PCS[0]

     * [23] LSBF           0b - MSB first

     * [22] BYSW           0b - Byte Swap is disabled

     * [21] CONT           0b - Continuous transfer is enabled

     * [20] CONTC          0b - Command word for start of new transfer

     * [19] RXMSK          0b - Normal transfer

     * [18] TXMSK          0b - Normal transfer

     * [17:16] WIDTH       00b - 1-bit transfer

     * [11:0] FRAMESZ      000000000111b - the frame size equals to 7+1 = 8 bits

     */

    LPSPI0->TCR = (LPSPI_TCR_CPOL(0b0) |

                  LPSPI_TCR_CPHA(0b1) |

                  LPSPI_TCR_PRESCALE(0b010) |

                  LPSPI_TCR_PCS(0b00) |

                  LPSPI_TCR_LSBF(0b0) |

                  LPSPI_TCR_BYSW(0b0) |

                  LPSPI_TCR_CONT(0b1) |

                  LPSPI_TCR_CONTC(0b0) |

                  LPSPI_TCR_RXMSK(0b0) |

                  LPSPI_TCR_TXMSK(0b0) |

                  LPSPI_TCR_WIDTH(0b00) |

                  LPSPI_TCR_FRAMESZ(7));

 

    /*  Clock Configuration register setup(SPLLDIV2_CLK/PRESCALE = 40MHz/4 = 10MHz <=> 100ns):

     * Field               Description

     * [31:24] SCKPCS      0x04 - SCK-to-PCS delay equals to (4+1 = 5)cycles of functional clock divided by TCR[PRESCALE]

     * [23:16] PCSSCK      0x09 - PCS-to-SCK delay equals to (9+1 = 10)cycles of functional clock divided by TCR[PRESCALE]

     * [15:8] DBT          0x1C - delay between transfers is (28+2 = 30)cycles of functional clock divided by TCR[PRESCALE]

     * [7:0] SCKDIV        0x08 - SCK period equals to (8+2 = 10)cycles of functional clock divided by TCR[PRESCALE]

     */

    LPSPI0->CCR |= LPSPI_CCR_SCKPCS(0xFF) |

                 LPSPI_CCR_PCSSCK(0xFF) |

                 LPSPI_CCR_DBT(28) |

                 LPSPI_CCR_SCKDIV(8);

 

 

    /* FIFO Control Register Configuration:

     * Field               Description

     * [17:16] RXWATER     00b - RX Flag is set when the number of words in RX FIFO > 0

     * [1:0] TXWATER       03b - TX Flag is set when the number of words in TX FIFO <= 0

     */

    LPSPI0->FCR |= LPSPI_FCR_RXWATER(0b00) | LPSPI_FCR_TXWATER(0b00);

 

    /* Enable LPSPI0 Module Configuration:

     * Field               Descriptions

     * [9] RRF             0b - Receive FIFO not reset

     * [8] RTF             0b - Transmit FIFO not reset

     * [3] DBGEN           1b - LPSPI module is disabled in debug mode

     * [2] DOZEN           0b - LPSPI module is enabled in Doze mode

     * [1] RST             0b - Module is not reset

     * [0] MEN             0b - Module is disabled

     */

    LPSPI0->CR |= LPSPI_CR_DBGEN(0b1) |

                 LPSPI_CR_MEN(0b1);

 

 

}

……

/* The host shall not send any further SPI frame to NJJ29C2

 * when the BUSY line is high, as it will not be stored and the data is lost.

 */

bool is_Busy_HighLevelvoid ) {

    bool tmp;

    tmp = (bool)((PTC->PDIR >> PTC10) & 1);

 

    return tmp;

}

 

uint8_t LPSPI0_Transmit_8bits(uint8_t *send, uint8_t txLength)

{

    uint8_t i;

    bool isHighLevel;

 

    /* the length should not be zero */

    if (0 == txLength) {

        return spiCom_False;

    }

 

    if (true == is_Busy_HighLevel()) {

        do {

           isHighLevel = is_Busy_HighLevel();

           if (timeout == is_timeout(5000)) {

 

               printf("\nCMD can not be send,because BUSY Line maintains high for 5s...");

 

               return spiCom_False;

           }

        } while(isHighLevel == is_Busy_HighLevel());

    }

 

 

    for(i = 0; i < txLength; i++)

    {

 

        /* wait for TX FIFO available */

        while(!(LPSPI0->SR & LPSPI_SR_TDF_MASK));

 

        /* transmit data */

        LPSPI0->TDR = send[i];

 

        if((i % 4) == 0) {

           LPSPI0_Set_TxDelay(0xC6); /* delay 20us between transfers */

        }

        else {

           LPSPI0_Set_TxDelay(0x1C); /* delay 3us between transfers */

        }

 

 

    }

 

    /* write an extra Transmit Command word to negative the SCSN */

        LPSPI0->TCR = (LPSPI_TCR_CPOL(0b0) |

                      LPSPI_TCR_CPHA(0b1) |

                      LPSPI_TCR_PRESCALE(0b010) |

                      LPSPI_TCR_PCS(0b00) |

                      LPSPI_TCR_LSBF(0b0) |

                      LPSPI_TCR_BYSW(0b0) |

                      LPSPI_TCR_CONT(0b1) |

                      LPSPI_TCR_CONTC(0b0) |

                      LPSPI_TCR_RXMSK(0b0) |

                      LPSPI_TCR_TXMSK(0b0) |

                      LPSPI_TCR_WIDTH(0b00) |

                      LPSPI_TCR_FRAMESZ(7));//0x53000007;

 

 

 

    return spiCom_Success;

}

1234

路过

雷人

握手

鲜花

鸡蛋

QQ|关于本站|小黑屋|Archiver|手机版|无线电爱好网 ( 粤ICP备15040352号 ) 无线电爱好技术交流5 无线电爱好技术交流1无线电爱好技术交流9开关电源讨论群LED照明应用、电源无线电爱好技术交流4无线电爱好技术交流8无线电爱好技术交流10无线电爱好技术交流11

粤公网安备 44030702001224号

GMT+8, 2023-2-16 10:41 , Processed in 0.124800 second(s), 17 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

返回顶部