@Robin_Shen ,
I studied the demo and attempted to reproduce it, following the documentation provided on the website: https://www.nxp.com/docs/en/reference-manual/KSDK12APIRM.pdf
In the documentation, it states:
1 - To initialize the LPSCI driver, call the LPSCI_DRV_Init() function and pass the instance number of the relevant LPSCI peripheral, memory for the run-time state structure, and a pointer to the user configuration structure. For example, to use LPSCI0 pass a value of 0 to the initialization function.
2 - Then, pass the memory for the run-time state structure and, finally, pass a user configuration structure of the type lpsci_user_config_t
lpsci_user_config_t lpsciConfig;
lpsciConfig.baudRate = 9600;
lpsciConfig.bitCountPerChar = kLpsci8BitsPerChar;
lpsciConfig.parityMode = kLpsciParityDisabled;
lpsciConfig.stopBitCount = kLpsciOneStopBit;
This example shows how to call the LPSCI_DRV_Init() function given the user configuration structure and the LPSCI instance 0.
uint32_t lpsciInstance = 0;
lpsci_state_t lpsciState; // user provides memory for the driver state structure
LPSCI_DRV_Init(lpsciInstance, &lpsciConfig, &lpsciState);
For blocking transfer functions transmit and receive:
uint8_t sourceBuff[26] ={0}; // sourceBuff is populated with desired data
uint8_t readBuffer[10] = {0}; // readBuffer is populated with LPSCI_DRV_ReceiveData function
uint32_t byteCount = sizeof(sourceBuff);
uint32_t rxRemainingSize = sizeof(readBuffer);
// for each use there, set timeout as "1"
// lpsciState is the run-time state. Pass in memory for this
// declared previously in the initialization chapter
LPSCI_DRV_SendDataBlocking(&lpsciState, sourceBuff, byteCount, 1); // function won’t return until transmit is complete
LPSCI_DRV_ReceiveDataBlocking(&lpsciState, readBuffer, 1, timeoutValue); //function won’t return until it receives all data
I tried to adapt the code as follows:
lpsci_user_config_t lpsciConfig;
lpsciConfig.baudRate = 115200;
lpsciConfig.bitCountPerChar = kLpsci8BitsPerChar;
lpsciConfig.parityMode = kLpsciParityDisabled;
lpsciConfig.stopBitCount = kLpsciOneStopBit;
uint32_t lpsciInstance = 0;
lpsci_state_t lpsciState;
LPSCI_DRV_Init(lpsciInstance, &lpsciConfig, &lpsciState);
uint8_t sourceBuff = 1;
uint32_t byteCount = sizeof(sourceBuff);
LPSCI_DRV_SendDataBlocking(&lpsciState, sourceBuff, byteCount, 1);
However, I am still unable to send anything through the USB port.
I am using PuTTY to monitor the USB port.
Could you please advise me on what I might be doing wrong?
Thank you for the help and patience.