Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

C18 formatting strings for usart

Status
Not open for further replies.
Thanks!!

Yep... the char buff[] is a RAM pointer to a char, and the = {"Hello"} tells the initialisation code to copy "Hello" from ROM space into RAM space for you. Your usart_str is (implictly) expecting a RAM pointer.

When you try usart_str("Hello") the compiler is putting "Hello" into ROM as it did for you previously, but is NOT doing the copy into RAM space. You would need to write a version of usart_str that took a (rom char *) pointer which read the ROM space char into a RAM variable to pass to write_usart()

Good to read both Section 5 of the Data Sheet, and section 2.4 of the C18 User's Guide.

P.

I have been beating myself silly trying to get the USART to transfer my message. Nearly one week on Microchips forum and nobody could answer this. I doubt I would ever see you in the states but I owe you a beer THANKS!
 
I have been beating myself silly trying to get the USART to transfer my message. Nearly one week on Microchips forum and nobody could answer this. I doubt I would ever see you in the states but I owe you a beer THANKS!

You're quite welcome :) Always good to share hard-won knowledge!

I do get to the US every year or two :)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top