AnsweredAssumed Answered

MK 64 UART0

Question asked by chaitanya Kulkarni on Jan 21, 2019
Latest reply on Jan 22, 2019 by Mark Butcher

Hello ,

I am using MK64 UART0 independently on PORT A 14,15 and PORTB  16,17  By using Pin mux. but i need to use UART0 on PORT B 16,17 and for Some instant we need to switch its PIN mux. on PORT A 14,15. and After that condition we need to re-innitialised to PORT B 16,17.

 

SO For Same thing i made on function in which 

i) Disable IRQ 31.

ii) Disable Transmission and Reception.

iii) Pin Muxing UART 0 For Particular pin.

iv) Re-Configure interrupt. 

 

after using this My function well Performing Transition from PORT B to PORT A Switching .but After PORT A 14,15 Transmission and Reception finished we are calling Same function then Switching from PORT A  to PORT B is not going to happen. 

 

 

Following Function  I Have Created 

/************************************************************************************************************/

void init_UART0_Printer_DSC_Selection(char DSC_PRINTER_VAL)
{

int CLK_VAL;

disable_irq(31); //FOR UART0 module
SIM_SOPT5 |= SIM_SOPT5_UART0RXSRC(0x00)|SIM_SOPT5_UART0TXSRC(0x00);

core_clk_mhz = EXTRENAL_CRYSTAL_SEL_MHZ; //100;
core_clk_khz = core_clk_mhz * 1000;
periph_clk_khz = core_clk_khz / (((SIM_CLKDIV1 & SIM_CLKDIV1_OUTDIV2_MASK) >> 24)+ 1);
if(DSC_PRINTER_VAL == DSC_SEL_VAL)
{

CLK_VAL = DSC_BAUD;
SIM_SOPT5 |= SIM_SOPT5_UART0RXSRC(0x00)|SIM_SOPT5_UART0TXSRC(0x00);

/************************************************************/
SIM_SCGC4 &= SIM_SCGC4_UART0_UNMASK; //CLOCK For UART0 Get Disable
UART_C2_REG(UART0_BASE_PTR) &= ~(UART_C2_TE_MASK | UART_C2_RE_MASK ); // DisableUART0
UART_C1_REG(UART0_BASE_PTR) = 0x00; /* We need all default settings, so entire register is cleared */
/************************************************************/
PORTB_PCR17 = PORT_PCR_MUX(0x3); //TX //PTB17 DSP_TXD UART0 //VBC 16th Feb. 2017
PORTB_PCR16 = PORT_PCR_MUX(0x3); //RX //PTB16 DSP_RXD UART0 //VBC 16th Feb. 2017
//OLD uart_init (UART0_BASE_PTR, periph_clk_khz, TERMINAL_BAUD); //UART3_BASE_PTR
uart_init (UART0_BASE_PTR, core_clk_khz, DSC_BAUD); //UART3_BASE_PTR - Updated 11-1-19

enable_irq(31); //FOR UART0 module
set_irq_priority(31,7); //Set priority
}
else if(DSC_PRINTER_VAL == PRINTER_SELECTION_VAL )
{
//DSC_SELECTED_OPERATION = 0;
CLK_VAL = TERMINAL_BAUD;
/************************************************************/
SIM_SCGC4 &= SIM_SCGC4_UART0_UNMASK; //CLOCK For UART0 Get Disable
UART_C2_REG(UART0_BASE_PTR) &= ~(UART_C2_TE_MASK | UART_C2_RE_MASK ); // DisableUART0
UART_C1_REG(UART0_BASE_PTR) = 0x00; /* We need all default settings, so entire register is cleared */
/************************************************************/
PORTA_PCR14 = PORT_PCR_MUX(0x3); //TX
PORTA_PCR15 = PORT_PCR_MUX(0x3); //RX

uart_init (UART0_BASE_PTR, core_clk_khz, TERMINAL_BAUD); //UART3_BASE_PTR

enable_irq(31); //FOR UART0 module
set_irq_priority(31,7); //Set priority
}
else
{

CLK_VAL = TERMINAL_BAUD;
SIM_SCGC4 &= SIM_SCGC4_UART0_UNMASK; //CLOCK For UART0 Get Disable
UART_C2_REG(UART0_BASE_PTR) &= ~(UART_C2_TE_MASK | UART_C2_RE_MASK ); // DisableUART0
UART_C1_REG(UART0_BASE_PTR) = 0x00; /* We need all default settings, so entire register is cleared */
/************************************************************/
PORTB_PCR17 = PORT_PCR_MUX(0x3); //TX //PTB17 DSP_TXD UART0 //VBC 16th Feb. 2017
PORTB_PCR16 = PORT_PCR_MUX(0x3); //RX //PTB16 DSP_RXD UART0 //VBC 16th Feb. 2017
//OLD uart_init (UART0_BASE_PTR, periph_clk_khz, TERMINAL_BAUD); //UART3_BASE_PTR
uart_init (UART0_BASE_PTR, core_clk_khz, DSC_BAUD); //UART3_BASE_PTR - Updated 11-1-19


enable_irq(31); //FOR UART3 module
set_irq_priority(31,7); //Set priority

}
/* Enable receiver and transmitter */
UART_C2_REG(UART0_BASE_PTR) |= (UART_C2_TE_MASK | UART_C2_RE_MASK | UART_C2_RIE_MASK| UART_RWFIFO_RXWATER(2));
sysclk_Cal = CLK_VAL; //Init required for UART init while config

}

/************************************************************************************************************/

 

Note that 

 

"DSC_PRINTER_VAL " is Use  For UART 0  on PORT B 16 and 17

"PRINTER_SELECTION_VAL " is Use  For UART 0  on PORT A 14 and 15

 

 

Please give me solution for same Problem

 

Outcomes