Hi all, Sorry if i am using bad English.
I am using UART Polled communication with the host ( Putty) over MKL46Z but i can not implement Software Flow Control (Xon/XOFF). It is posibble ? Below show the code i use to do communication task
#include "MKL46Z4.h"
#include "TxRxQueues.h"
#define UART_BUFF_SIZE (10)
char RxQBuffer[UART_BUFF_SIZE], TxQBuffer[UART_BUFF_SIZE];
struct qRecord RxQueue, TxQueue;
void UART_Init()
{
//clock init
init_Queue(&RxQueue, RxQBuffer, UART_BUFF_SIZE);
init_Queue(&TxQueue, TxQBuffer, UART_BUFF_SIZE);
SIM->SCGC4 |= SIM_SCGC4_UART2_MASK; /* Enable Clock to UART2*/
// PTA1 -> ALT3 = UART2_RX
// PTA2 -> ALT3 = UART2_TX
SIM->SCGC5 |= SIM_SCGC5_PORTE_MASK; /* Enable Clock to PORTA*/
PORTE->PCR[16] |= PORT_PCR_MUX(3UL); /* Pin PTA1 is alt2 (UART)*/
PORTE->PCR[17] |= PORT_PCR_MUX(3UL); /* Pin PTA2 is alt2 (UART) */
UART2->C2 &= !UART_C2_TE_MASK; /* disable transmitting*/
UART2->C2 &= !UART_C2_RE_MASK; /* disable receiving */
UART2->BDH |= UART_BDH_SBR(0); /*set value of SBR to BDH (it is the first divider)*/
UART2->BDL |= UART_BDL_SBR(0x185); /*set value of SBR to BDL 26*/
UART2->BDH &= !UART_BDH_SBNS_MASK; /*set value of SBNS (0 - one bit, 1- two bits) */
UART2->C1 &= !UART_C1_M_MASK; /* M selects between 8 and 9 bits data MODE*/
UART2->C1 &= !UART_C1_PE_MASK; /* PE - parity enable (0 - no hardware parity)*/
//UART2->C2 |= UART2_C2_TIE_MASK; /* enable interrupt*/
//UART2->C2 |= UART2_C2_RIE_MASK;
UART2->C2 |= UART_C2_TE_MASK; /* enable transmitting*/
UART2->C2 |= UART_C2_RE_MASK; /* enable receiving */
}
void Send(uint8_t message)
{
// Send message
UART2->D= message;
// Wait for transfer complete
while(!(UART2->S1 & UART_S1_TDRE_MASK)){}
//while(!(UART2->S1 & UART_S1_TC_MASK)){}
}
char getChar() {
char character;
int success;
do {
__asm("CPSID I");
success = dequeue(&character, &RxQueue);
__asm("CPSIE I");
} while (!success);
return character;
}
Hi Diego,
KL46 can support software flow control. Please refer to this case link https://community.nxp.com/message/511094
KL26 UART port is same to KL46. Hope this can help you.
Regards,
Jing
Hi
KL46 XON/XOFF SW and RTS/CTS HW flow control are included in the uTasker project - see the open source link below and the UART document: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF
Note that XON/XOFF flow control is implemented at the driver level and not in the UART HW.
Regards
Mark
Complete Kinetis solutions for professional needs, training and support: http://www.utasker.com/kinetis.html
Kinetis KL25, KL26, KL27, KL28, KL43, KL46, KL82
- http://http://www.utasker.com/kinetis/FRDM-KL25Z.html
- http://www.utasker.com/kinetis/TWR-KL25Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL26Z.html
- http://www.utasker.com/kinetis/TEENSY_LC.html
- http://www.utasker.com/kinetis/FRDM-KL27Z.html
- http://www.utasker.com/kinetis/Capuccino-KL27.html
- http://www.utasker.com/kinetis/FRDM-KL28Z.html
- http://www.utasker.com/kinetis/FRDM-KL43Z.html
- http://www.utasker.com/kinetis/TWR-KL43Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL46Z.html
- http://www.utasker.com/kinetis/TWR-KL46Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL82Z.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html
Open Source version at https://github.com/uTasker/uTasker-Kinetis