Electronics > Microcontrollers

Using printf with msp432e401y microcontroller

(1/3) > >>

Thomas83:
Hello everyone!

I just started working with the MSP432E401Y launchpad. My goal for  is to send some data to a terminal via UART0.
I am having trouble with the PRINTF Function, any data do not send to the terminal. It would be really difficult to implement what I need without these printf function.

Any help or an example would be greatly appreciated!

nctnico:
You'll likely need to write your own putchar() and puts() functions to send data to the serial port.

Bassman59:

--- Quote from: Thomas83 on May 23, 2022, 09:28:41 am ---Hello everyone!

I just started working with the MSP432E401Y launchpad. My goal for  is to send some data to a terminal via UART0.
I am having trouble with the PRINTF Function, any data do not send to the terminal. It would be really difficult to implement what I need without these printf function.

Any help or an example would be greatly appreciated!

--- End quote ---

All of the examples TI provides with CCS for this part use a function UARTprintf() which is defined/declared in the files uartstdio.c/.h.

SiliconWizard:

--- Quote from: nctnico on May 23, 2022, 09:34:35 am ---You'll likely need to write your own putchar() and puts() functions to send data to the serial port.

--- End quote ---

Yes. I suspect TI already has working examples for this.

Another approach, more flexible and not requiring to know how to do the above is to implement your own function, using snprintf() instead for the formatting, an intermediate buffer, and then sending the buffer to whatever peripheral.

nctnico:

--- Quote from: SiliconWizard on May 23, 2022, 04:58:02 pm ---
--- Quote from: nctnico on May 23, 2022, 09:34:35 am ---You'll likely need to write your own putchar() and puts() functions to send data to the serial port.

--- End quote ---

Yes. I suspect TI already has working examples for this.

Another approach, more flexible and not requiring to know how to do the above is to implement your own function, using snprintf() instead for the formatting, an intermediate buffer, and then sending the buffer to whatever peripheral.

--- End quote ---
That snprint method is messy. You'll need to declare a buffer and then transmit the data. Having the regular printf() working to write to a console output (in this case a serial port) makes code much cleaner and portable.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version