Can't get PIC24F UART to work @ 250Kb

126 views
Skip to first unread message

vass

unread,
Oct 5, 2011, 6:14:40 PM10/5/11
to PIC24 Assembly-to-C Book
Hello;
I am trying to get the UART on the PIC24FJ64GB004 to communicate @
250Kb but without any success.

1/ I tried both BRGH = 0 & BRGH = 1, each time I tried to play
around with the calculated values.

2/ I tried doing it via Bit-Banging but because I am very new to the
PIC24 instruction set, it did not work. Whenever I try to CALL a
routine the valued in some of my registers change right after the CALL
instruction. Also, whenever I tried INC Ws,Wd, Ws refuses to
increments more than once etc, etc..

3/ Both Internal and External Oscillators (with and without PLL) were
used.

4/ I did not find any errata on this module.

250Kb is the speed at which the DMX Protocol (for stage lighting)
operates. 1 Start Bit, 8 Data Bits, no Parity and 2 Stop Bits.

PIC24 Assembly-to-C Book has helped a lot but I still need assistance.
I would be very grateful if someone could show me what I am doing
wrong.

Thanks

Robert Reese

unread,
Oct 6, 2011, 10:38:23 AM10/6/11
to pic24-assemb...@googlegroups.com
The max speed that we have been able to get work reliably is 115K baud, and that only with the PIC24H family when it is using the PLL and operating at a 40MHz instruction clock frequency.

We have also not had much luck getting the BRGH =1 mode (4 clock sampling per bit) to work reliably, which really limits you on the high end.




--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To post to this group, send email to pic24-assemb...@googlegroups.com.
To unsubscribe from this group, send email to pic24-assembly-to-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pic24-assembly-to-c-book?hl=en.


David Vassell

unread,
Oct 6, 2011, 11:58:25 AM10/6/11
to pic24-assemb...@googlegroups.com

Hello;

 

Thank you very much for your vary quick response.  Thank you for letting me realise that I am not doing anything wrong.   I just wish that Microchip would say this in their data sheet.  I am still working on a BIT BANGING solution to my code.  As soon as I have it working, I would like, with your permission, to post it to your forum.

 

Best regards

Dave

Robert Reese

unread,
Oct 6, 2011, 11:43:56 PM10/6/11
to pic24-assemb...@googlegroups.com
Good luck! And sure, feel free to post the code, that would be nice to have.

 Bob R

David Vassell

unread,
Nov 1, 2011, 3:45:02 PM11/1/11
to pic24-assemb...@googlegroups.com

Hello,

 

Recently I contacted you re not getting  the PIC24FJ64GB004 to communicate @ 250Kb.  Well after much disappointment trying to use BIT-BANGING method I finally got the code to work, may be it was serendipity or happenstance. I have attached a copy of the code.

 

The following three (3) lines were added to the function  void SEND_DMX_Data (int RS232_OUT)  in the original code  

 

BIT_OUT = 1;                           // Set UART O/P pin HI

            DELAY_52_MicroSec ();          // Adding these three (3) additional lines of code (BIT_OUT = 1  and   DELAY_52_MicroSec () )  made the difference.

            DELAY_52_MicroSec ();          // Before these lines of code the code would not work

 

As I mentioned before, I am new at programming in C and am in need of a little help.  How would I set up a Buffer to transmit and receive? And how would I access the data in the buffer?  Your help would be very appreciated.

 

Thank so much.

 

Dave

   

 

From: pic24-assemb...@googlegroups.com [mailto:pic24-assemb...@googlegroups.com] On Behalf Of Robert Reese
Sent: Thursday, October 06, 2011 10:38 AM
To: pic24-assemb...@googlegroups.com
Subject: Re: Can't get PIC24F UART to work @ 250Kb

 

The max speed that we have been able to get work reliably is 115K baud, and that only with the PIC24H family when it is using the PLL and operating at a 40MHz instruction clock frequency.

TX_at_250

Bryan A. Jones

unread,
Nov 2, 2011, 12:15:23 PM11/2/11
to pic24-assemb...@googlegroups.com
Dave,

The code you show forces the line to remain in an idle state for a bit length or two -- did you send the stop bit(s) at the end of the data bits?

For buffering, take a look at 115 and following of http://www.ece.msstate.edu/courses/ece3724/main_pic24/docs/pic24__uart_8c_source.html for an example.

Hope that helps!

Bryan
Bryan A. Jones, Ph.D.
Associate Professor
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi state, MS 39762
http://www.ece.msstate.edu/~bjones
bjones AT ece DOT msstate DOT edu
voice 662-325-3149
fax 662-325-2298

Our Master, Jesus Christ, is on his way. He'll show up right on
time, his arrival guaranteed by the Blessed and Undisputed Ruler,
High King, High God.
- 1 Tim. 6:14b-15 (The Message)

David Vassell

unread,
Nov 3, 2011, 1:30:26 PM11/3/11
to pic24-assemb...@googlegroups.com

Bryan,

Thanks very much for providing me with the requested information.

Yes, the code sends two Stop Bits ( Bit 0 of  U1MODE  is set to ‘1’ ---  U1MODE = 0x8809; )

Also, my calculation for “DELAY_52_MicroSec ()” was incorrect.  The value I had, yields a delay much greater than 52 µs.     

Dave

TX_at_250
Reply all
Reply to author
Forward
0 new messages