All,
I'm having what appears to be a very basic problem implementing an LPUART set of functions, but I've been stuck for most of a day now so I'm turning to the community.
The code is interrupt driven in order to handle the high output rate without blocking my other code. I've attached the .c and related header file, but a summary of the problem is below:
After Initialize is called, the registers are in the following state:
LPUART_BAUD: 0x19000008
LPUART_STAT: 0x00800000
LPUART_CTRL: 0x000C0000
LPUART_DATA: 0x00001000
LPUART_MATCH: 0x00000000
The init function is based on the example init function that comes with the KSDK for the KL27 freedom board.
When I Tx, I set the TIE bit in CTRL so that the interrupt fires. When the ISR is called, it checks a pointer that is passed to the Tx function for the next byte, writes it to the DATA register, and returns, repeating until the full length of the buffer has been handled this way. When there are no bytes left in the buffer, the ISR clears the TIE bit until a new Tx is called for, when the entire process should repeat.
I am able to confirm that the ISR is called once, and not again. I am also able to see that the TDRE bit is not ever set after the initial write to the DATA register. I'm using a18 for the Rx, and a19 for the Tx. Their port control registers after initialization have the mux values set to 3, and the PDDR register shows the appropriate direction for both pins. The TE and RE bits are set in CTRL. I'm not sure what I'm missing.
If I put an oscilloscope on the Tx pin, I do not see any signal at all (not even the first byte I write to the DATA register). It looks to me like the shift register is not emptying the DATA register, but I can't find any errata or documentation that would suggest why this would be happening.
Any help would be greatly appreciated!
Best,
Don
Original Attachment has been moved to: LPUART_HAL.c.zip
Original Attachment has been moved to: LPUART_HAL.h.zip
Solved! Go to Solution.
Hi
Most likely you haven't configured a clock to the LPUART and it then never sends out data. Check SIM_SOPT2 and MCG_MC settings to be suitable for the clock source you want to use.
Use the uTasker UART driver as reference (it works with all chips and automatically adapts itself to UART or LPUART in interrupt driven or DMA Tx and Rx modes).
All code at http://www.utasker.com/kinetis.html which also allows emulating the LPUART in real-time for developments and study, as well as allowing verifying pin muxing accuracy.
Its UART features are documented at http://www.utasker.com/docs/uTasker/uTaskerUART.PDF
(whereby the serial operation includes a powerful command line shell, ASCII/RTU MODBUS functionality as well as PPP for use with the uTasker's integrated TCP/IP stack for complete reliable project solutions without development complications and time loss).
Regards
Mark
Hi
Most likely you haven't configured a clock to the LPUART and it then never sends out data. Check SIM_SOPT2 and MCG_MC settings to be suitable for the clock source you want to use.
Use the uTasker UART driver as reference (it works with all chips and automatically adapts itself to UART or LPUART in interrupt driven or DMA Tx and Rx modes).
All code at http://www.utasker.com/kinetis.html which also allows emulating the LPUART in real-time for developments and study, as well as allowing verifying pin muxing accuracy.
Its UART features are documented at http://www.utasker.com/docs/uTasker/uTaskerUART.PDF
(whereby the serial operation includes a powerful command line shell, ASCII/RTU MODBUS functionality as well as PPP for use with the uTasker's integrated TCP/IP stack for complete reliable project solutions without development complications and time loss).
Regards
Mark
You were right on the money with SIM_SOPT2. I had it setup with SCG and didn't realize it took a separate clock in addition to that. Thanks for the fast response!