I'm using UART to interface with a chip which implements a "safe mode" UART configuration in which the chip runs it's UART port with a standard, known parameters set - this allow recovering from configuration errors.
To trigger such "safe mode" I need to hold UART Tx at low, for a predefined, long time. What would be the best way to accomplish that? Changing the port configuration to GPIO, and than back to UART?
I try to firat set UART Configration and then second set GPIO. But not conversion to GPIO.
Help me Plase.
<1>
void Uart_SetUArt0(void) /* Init. summary: 500000 baud, 1 stop bit, 8 bit format, no parity */
{
PCC->PCCn[PCC_LPUART0_INDEX] &= ~PCC_PCCn_CGC_MASK; /* Ensure clk disabled for config */
PCC->PCCn[PCC_LPUART0_INDEX] |= PCC_PCCn_PCS(6) /* Clock Src= 1 (SOSCDIV2_CLK) */
| PCC_PCCn_CGC_MASK; /* Enable clock for LPUART1 regs */
LPUART0->BAUD =0x09000002; /* SBR = 2, OSR = 10(9+1), 10,000,000/(2*10) = 500,000 */
LPUART0->CTRL=0x002C0000; /* Enable transmitter & receiver, no parity, 8 bit char: */
/* RE=1: Receiver enabled */
/* TE=1: Transmitter enabled */
/* PE,PT=0: No hw parity generation or checking */
/* M7,M,R8T9,R9T8=0: 8-bit data characters*/
/* DOZEEN=0: LPUART enabled in Doze mode */
/* ORIE,NEIE,FEIE,PEIE,TIE,TCIE,RIE,ILIE,MA1IE,MA2IE=0: no IRQ*/
/* TxDIR=0: TxD pin is input if in single-wire mode */
/* TXINV=0: TRansmit data not inverted */
/* RWU,WAKE=0: normal operation; rcvr not in statndby */
/* IDLCFG=0: one idle character */
/* ILT=0: Idle char bit count starts after start bit */
/* SBK=0: Normal transmitter operation - no break char */
/* LOOPS,RSRC=0: no loop back */
}
PCC->PCCn[PCC_PORTC_INDEX ]|=PCC_PCCn_CGC_MASK; /* Enable clock for PORTC */
PORTC->PCR[2]|=PORT_PCR_MUX(4); /* Port C2: MUX = ALT4,UART0 RX */
PORTC->PCR[3]|=PORT_PCR_MUX(4); /* Port C3: MUX = ALT4,UART0 TX */
<2>
PCC->PCCn[PCC_PORTC_INDEX ]|= PCC_PCCn_CGC_MASK; /* Enable clock for PORT */
PORTC->PCR[3]|=PORT_PCR_MUX(1); /* GPIO OUT */
PTC->PDDR |= 1<<3;
PTC->PCOR |= 1<<3; /* LOW */
Best regards,
kwak
Hello kwakd.y,
You solution should work.
If I understand, you are not able to reconfigure the port to GPIO.
I guess this is because you read-modify-write the PCR register.
Your code:
PORTC->PCR[3]|=PORT_PCR_MUX(4);
PORTC->PCR[3]|=PORT_PCR_MUX(1);
sets the PCR_MUX to 0x5 = 0x4 | 0x1.
How long does the TX pin need to be low?
The LPUART can send a break character:
BR, Daniel