Use EXTAL0 and XTAL0 pins in UART mode

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Use EXTAL0 and XTAL0 pins in UART mode

Jump to solution
955 Views
alex323qp
Contributor III

Hi, I have a custom board with a MKL25Z128 MCU. The MCG is configured in FEI mode (internal clock source) and I'm trying to repurpose the EXTAL0 and XTAL0 pins for serial communication (UART1).

(My project uses mbed libraries, but I'm comfortable manipulating the registers directly if required)

mbed has a DigitalOut library for generic I/O purposes that works fine over the PTA19 pin. The problem is that if I replace it with the serial instance (using the Serial library), the program stops working. My guess is that there is something in that library that conflicts with my configurations.

I tried to set the ALT mode 3 directly thinking that was the problem but no luck whatsoever:

PORTA->PCR[19] = PORT_PCR_MUX(3);

PORTA->PCR[18] = PORT_PCR_MUX(3);

I wonder if there is something else I'm supposed to do in order to free these pins and use the UART module available to them?

Any help would be greatly appreciated.

Regards,

Alex.

0 Kudos
1 Solution
710 Views
alex323qp
Contributor III

I figured out what the problem was:

Mbed's PinMap module did not include the PTA18 and PTA19 pins as part of the UART Peripheral. The fix was just to add both pins and the alt mode to the PinMap_UART_TX structure in the PeripheralPins.c file.

Hope this helps someone else.

Regards,

Alex.

View solution in original post

0 Kudos
4 Replies
711 Views
alex323qp
Contributor III

I figured out what the problem was:

Mbed's PinMap module did not include the PTA18 and PTA19 pins as part of the UART Peripheral. The fix was just to add both pins and the alt mode to the PinMap_UART_TX structure in the PeripheralPins.c file.

Hope this helps someone else.

Regards,

Alex.

0 Kudos
710 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Alex,

Could you show your code about how to configure the UART1 ?

And have you enable the UART1 clock ?

Have you IDE can debug your project , if have , i recommend you first debug it to be sure the code can work well ,

and the project only with UART1 , thus we can locate the problem quickly .

BR

Alice

0 Kudos
710 Views
alex323qp
Contributor III

Hi Alice,

Thanks for your response.

All the UART setup is done by the mbed libraries, so I'll have to check the source code to see what configurations are being used. Since this is a custom board, I don't yet have debugging capabilities; that is in fact the purpose of getting the UART working to use it as an improvised way of getting debugging statements out of the chip.

Can you point me out to the chapter in the datasheet regarding the UART clock configuration? That would really help me find my way through the mbed libraries and figure out whether it is active or not.

Cheers,

Alex.

0 Kudos
710 Views
alex323qp
Contributor III

After having a quick look to the mbed's serial_api.c library, it seems that the UART1 clock is being enabled:

SIM->SCGC4 |= SIM_SCGC4_UART1_MASK;

I also tested adding the line to my main() method (just in case), but the problem persists. Any other idea?

Cheers,

A.

0 Kudos