USART programming

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
jcooper
Posts: 23
Joined: Tue Jul 08, 2008 7:29 pm
Contact:

USART programming

Post by jcooper »

I'm working on a PIC18f452, plugged into the HP-488-00-3 demo board, and I'm having issues with the USART. Does anyone have C source code for a simple USART RS232 protocol demonstration? It would be nice to get some for-sure-working code so that I can test the physical setup separately from my code.
No trees were harmed in the posting of this message. However, a large number of electrons were terribly inconvenienced.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: USART programming

Post by Benj »

Hello

Which device are you using? Which clock speed? Which Baud rate required?

I will generate you the code to drive the particular device at the particular clock speed and baud.

jcooper
Posts: 23
Joined: Tue Jul 08, 2008 7:29 pm
Contact:

Re: USART programming

Post by jcooper »

Benj wrote:Hello

Which device are you using? Which clock speed? Which Baud rate required?

I will generate you the code to drive the particular device at the particular clock speed and baud.
I'm programming with an MPLAB ICD2 debugger, the board is running off the RC circuit at 3.46MHz. Any baud rate is fine for now, probably something in the mid-range available with these settings.
No trees were harmed in the posting of this message. However, a large number of electrons were terribly inconvenienced.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: USART programming

Post by Benj »

Hello

Here is the complete C program for the RS232 UART running at a baud of 4800.
Attachments
Flowcode1.c
(7.48 KiB) Downloaded 513 times

Post Reply