PIC24HJ64GP210A Framing errors at high temperature

49 views
Skip to first unread message

Sergio Galmez

unread,
Nov 16, 2017, 10:22:56 AM11/16/17
to PIC24 Assembly-to-C Book

Hi,

I’m having problems with framing errors when the temperature is in the range of +/- 160 degree F, otherwise it communicate with no problem.

The code has been use on a PIC24HJ64GP210A 64 pins for about 8 years, with no issues, I needed to add more PWMs and Inputs, so I moved to the same chip, but with 100 pins configuration.

I’m using UART1 for communication over rs485, the RX is interrupt driven, not the TX which I use the outChar1 (). The communication its setup to a bout rate of 38400 and 8-bit no parity with one stop bit.

I also revisit the Oscillator configuration and redesigned the external crystal oscillator resonant circuit to ensure proper clock measuring.

The way that is designed is to have 8 PWM and 32 inputs, separated on two messages, on the first message, the controller send the first 4 PWM and the first 16 inputs readings, on the second message send the next 4 PWM and the next 16 inputs readings.

Is in the second message where the framing errors appear, losing communication with the master controller.  As I mention before the framing errors start happening when temperatures are in the range of 160 degree F. With temperatures less than 160 degree F there is no communication errors. The chip is rated to 185 degree F.

I’ve tested with a PIC24HJ64GP510A extended temperature rated for 257 degree F, and I still have the framing errors at the 160 degree range, that lead me to review the configuration setting .

I need you help to figure this out; if you please give me some sense of direction I’ll be grateful.

Thank you

Jones, Bryan

unread,
Nov 16, 2017, 10:32:50 AM11/16/17
to pic24-assemb...@googlegroups.com
Sergio,

Hmmm, that's definitely a hard problem. What's clock frequency does your PIC run at? How did you configure the serial port? In your UART configuration, do you use BRGH=1 or 0? When 1, I've seen fairly poor behavior -- 0 is much better. If you put your TX output on a logic analyzer, what is the measured baud rate? I wonder if your PIC's serial clock is off by a bit.

Bryan

--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-c-book+unsub...@googlegroups.com.
To post to this group, send email to pic24-assembly-to-c-book@googlegroups.com.
Visit this group at https://groups.google.com/group/pic24-assembly-to-c-book.
For more options, visit https://groups.google.com/d/optout.



--
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)

Sergio Galmez

unread,
Nov 16, 2017, 10:35:17 PM11/16/17
to PIC24 Assembly-to-C Book

Hi Bryan,

Thanks for you respond.

The clock is setup with an external crystal oscillator of 8MHz as follow:


void configClockPRIPLL_8MHzCrystal_40MHzFCY(void)

{

  switchClock(GET_OSC_SEL_BITS(FNOSC_FRC));

  _PLLPRE = 0; // Prescale = PLLPRE + 2

  _PLLDIV = 38; // Multiply = PLLDIV + 2

  _PLLPOST = 0; // Postscale = 2 * (PLLPOST + 1)

  switchClock(GET_OSC_SEL_BITS(FNOSC_PRIPLL));

}


And yes, the BRGH = 1. The UART is set like this:


  CONFIG_BAUDRATE_UART1(38400);  

  CONFIG_PDSEL_UART1(UXMODE_PDSEL_8DATA_NOPARITY);      

  CONFIG_STOPBITS_UART1(1);    


As mention before, the RX is Interrupt driven but not the TX.

I also have a 500 microseconds delay, to give the transceiver time to settle.

I don’t have a frequency analyzer on hand at this moment.


Sergio


On Thursday, November 16, 2017 at 10:32:50 AM UTC-5, Bryan A. Jones wrote:
Sergio,

Hmmm, that's definitely a hard problem. What's clock frequency does your PIC run at? How did you configure the serial port? In your UART configuration, do you use BRGH=1 or 0? When 1, I've seen fairly poor behavior -- 0 is much better. If you put your TX output on a logic analyzer, what is the measured baud rate? I wonder if your PIC's serial clock is off by a bit.

Bryan
On Wed, Nov 15, 2017 at 2:55 PM, Sergio Galmez <ke...@hotmail.com> wrote:

Hi,

I’m having problems with framing errors when the temperature is in the range of +/- 160 degree F, otherwise it communicate with no problem.

The code has been use on a PIC24HJ64GP210A 64 pins for about 8 years, with no issues, I needed to add more PWMs and Inputs, so I moved to the same chip, but with 100 pins configuration.

I’m using UART1 for communication over rs485, the RX is interrupt driven, not the TX which I use the outChar1 (). The communication its setup to a bout rate of 38400 and 8-bit no parity with one stop bit.

I also revisit the Oscillator configuration and redesigned the external crystal oscillator resonant circuit to ensure proper clock measuring.

The way that is designed is to have 8 PWM and 32 inputs, separated on two messages, on the first message, the controller send the first 4 PWM and the first 16 inputs readings, on the second message send the next 4 PWM and the next 16 inputs readings.

Is in the second message where the framing errors appear, losing communication with the master controller.  As I mention before the framing errors start happening when temperatures are in the range of 160 degree F. With temperatures less than 160 degree F there is no communication errors. The chip is rated to 185 degree F.

I’ve tested with a PIC24HJ64GP510A extended temperature rated for 257 degree F, and I still have the framing errors at the 160 degree range, that lead me to review the configuration setting .

I need you help to figure this out; if you please give me some sense of direction I’ll be grateful.

Thank you

--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-c-book+unsub...@googlegroups.com.
To post to this group, send email to pic24-assem...@googlegroups.com.

Jones, Bryan

unread,
Nov 16, 2017, 10:50:16 PM11/16/17
to pic24-assemb...@googlegroups.com
I would definitely move to BRGH = 0. This may fix your problem -- at 16, it does a much better job of sampling a bit in the middle. I've seen marginal behavior with BRGH = 1. At Fcy = 40 MHz, I think you can pick BRGH = 0 and U1BRG = 64 to get a baud rate of 38,461 baud. (If you used a different crystal -- the 7.37 MHz, I think -- baud rates come out exactly). That's an error of 0.16%, which over 10 bits (1 start + 8 data + 1 stop) is 1.6%, which should be fine.

On Thu, Nov 16, 2017 at 2:58 PM, Sergio Galmez <ke...@hotmail.com> wrote:

Hi Bryan,

Thanks for you respond.

The clock is setup with an external crystal oscillator of 8MHz as follow:


void configClockPRIPLL_8MHzCrystal_40MHzFCY(void)

{

  switchClock(GET_OSC_SEL_BITS(FNOSC_FRC));

  _PLLPRE = 0; // Prescale = PLLPRE + 2

  _PLLDIV = 38; // Multiply = PLLDIV + 2

  _PLLPOST = 0; // Postscale = 2 * (PLLPOST + 1)

  switchClock(GET_OSC_SEL_BITS(FNOSC_PRIPLL));

}


And yes, the BRGH = 1. The UART is set like this:


  CONFIG_BAUDRATE_UART1(38400);  

  CONFIG_PDSEL_UART1(UXMODE_PDSEL_8DATA_NOPARITY);      

  CONFIG_STOPBITS_UART1(1);    


As mention before, the RX is Interrupt driven but not the TX.

I also have a 500 microseconds delay, to give the transceiver time to settle.

I don’t have a frequency analyzer on hand at this moment.


Sergio

On Thursday, November 16, 2017 at 10:32:50 AM UTC-5, Bryan A. Jones wrote:
Sergio,

Hmmm, that's definitely a hard problem. What's clock frequency does your PIC run at? How did you configure the serial port? In your UART configuration, do you use BRGH=1 or 0? When 1, I've seen fairly poor behavior -- 0 is much better. If you put your TX output on a logic analyzer, what is the measured baud rate? I wonder if your PIC's serial clock is off by a bit.

Bryan
On Wed, Nov 15, 2017 at 2:55 PM, Sergio Galmez <ke...@hotmail.com> wrote:

Hi,

I’m having problems with framing errors when the temperature is in the range of +/- 160 degree F, otherwise it communicate with no problem.

The code has been use on a PIC24HJ64GP210A 64 pins for about 8 years, with no issues, I needed to add more PWMs and Inputs, so I moved to the same chip, but with 100 pins configuration.

I’m using UART1 for communication over rs485, the RX is interrupt driven, not the TX which I use the outChar1 (). The communication its setup to a bout rate of 38400 and 8-bit no parity with one stop bit.

I also revisit the Oscillator configuration and redesigned the external crystal oscillator resonant circuit to ensure proper clock measuring.

The way that is designed is to have 8 PWM and 32 inputs, separated on two messages, on the first message, the controller send the first 4 PWM and the first 16 inputs readings, on the second message send the next 4 PWM and the next 16 inputs readings.

Is in the second message where the framing errors appear, losing communication with the master controller.  As I mention before the framing errors start happening when temperatures are in the range of 160 degree F. With temperatures less than 160 degree F there is no communication errors. The chip is rated to 185 degree F.

I’ve tested with a PIC24HJ64GP510A extended temperature rated for 257 degree F, and I still have the framing errors at the 160 degree range, that lead me to review the configuration setting .

I need you help to figure this out; if you please give me some sense of direction I’ll be grateful.

Thank you

--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-c-book+unsubscr...@googlegroups.com.
To post to this group, send email to pic24-assem...@googlegroups.com.

Sergio Galmez

unread,
Nov 17, 2017, 11:50:10 AM11/17/17
to PIC24 Assembly-to-C Book

I see the difference in the Calculations with BRGH = 0, based on the Baud Rate Calculation (DS39708 Pg. 12), now I have a Baud Rate of 38400.688, I think that is very accurate.

I tested and the problem persists. I’m guessing that is timing issue, but if the temperature still within range (less than 160 degree F), what can be changing the timing to create framing errors? Is there any way to see how the clock behavior is when these framing errors occurred? At this point I can only calculate the clock timers.

 I attached the schematic in case I’m missing something.

Thank you

Sergio

To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-c-book+unsub...@googlegroups.com.
To post to this group, send email to pic24-assem...@googlegroups.com.
Visit this group at https://groups.google.com/group/pic24-assembly-to-c-book.
For more options, visit https://groups.google.com/d/optout.



--
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)

--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-c-book+unsub...@googlegroups.com.
To post to this group, send email to pic24-assem...@googlegroups.com.
Visit this group at https://groups.google.com/group/pic24-assembly-to-c-book.
For more options, visit https://groups.google.com/d/optout.
Schematic MICRO.pdf

Jones, Bryan

unread,
Nov 17, 2017, 11:57:30 AM11/17/17
to pic24-assemb...@googlegroups.com
I'm not sure. Have you looked at the RX and TX signals on a scope to verify the actual timing?

On Fri, Nov 17, 2017 at 10:40 AM, Sergio Galmez <ke...@hotmail.com> wrote:

I see the difference in the Calculations with BRGH = 0, based on the Baud Rate Calculation (DS39708 Pg. 12), now I have a Baud Rate of 38400.688, I think that is very accurate.

I tested and the problem persists. I’m guessing that is timing issue, but if the temperature still within range (less than 160 degree F), what can be changing the timing to create framing errors? Is there any way to see how the clock behavior is when these framing errors occurred? At this point I can only calculate the clock timers.

 I attached the schematic in case I’m missing something.

Thank you

Sergio

Matt Stowell

unread,
Nov 17, 2017, 1:58:05 PM11/17/17
to pic24-assemb...@googlegroups.com
Hello Sergio,

I have been following the dialog and thought I would add a thought of my own.  I would do as Bryan suggests; confirm timing with a scope.  You will likely discover that the baud rate has shifted on you at high temperatures.  All timing is derived from the crystal, Y1, that you show on your schematic. Check the tempco of the crystal and make sure it is very low.  If the tempco is high, your base oscillator frequency will move with temperature and cause your baud rate to move as well, which will cause your framing error.  You could also measure the crystal frequency at normal and high temperatures to prove the case.  Good luck; let us know how it turns out!

-Matt




--
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)

Sergio Galmez

unread,
Nov 17, 2017, 3:46:17 PM11/17/17
to Jones, Bryan, pic24-assemb...@googlegroups.com


From: pic24-assemb...@googlegroups.com <pic24-assemb...@googlegroups.com> on behalf of Jones, Bryan <bjo...@ece.msstate.edu>
Sent: Friday, November 17, 2017 11:57 AM
To: pic24-assemb...@googlegroups.com
Subject: Re: PIC24HJ64GP210A Framing errors at high temperature
 
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-...@googlegroups.com.
To post to this group, send email to pic24-assemb...@googlegroups.com.

Sergio Galmez

unread,
Nov 17, 2017, 3:46:17 PM11/17/17
to PIC24 Assembly-to-C Book

Yes, I did check the Rx/Tx on the scope, the length of the message and the timing are correct

Robert Reese

unread,
Nov 17, 2017, 4:51:43 PM11/17/17
to pic24-assemb...@googlegroups.com
Sergio -- how you are checking the 485TX/485RX PCB signals on a scope when the temperature is above 160F? Do you have a temp chamber with the ability to bring signals from the PCB out for external monitoring?

I agree with Bryan's suggestions -- I have experienced framing errors at normal temps for some higher baud rates when trying to use BRGH =1. I have never had problems with  BRGH =0.

And, I agree with Matt Stowell -- at this point, I think the problem may be with some component other than the PIC24.  What about U5, the LTC485 RS485 transceiver?  Are you using the extended range temperature version of this device? The normal range for this tops out at 70C (158 F).

Bob Reese




On Fri, Nov 17, 2017 at 11:11 AM, Sergio Galmez <ke...@hotmail.com> wrote:

Yes, I did check the Rx/Tx on the scope, the length of the message and the timing are correct

--

Sergio Galmez

unread,
Dec 4, 2018, 10:01:46 AM12/4/18
to PIC24 Assembly-to-C Book
Sorry for take me so long to get back to this issue, I was really busy with other projects.

I did resolve this problem when I was testing and following the advice received here. I wanted to get back to explain how i got this fixed, since I didn't want to leave an open topic.
At the end I fine that the path of the crystal oscillator where designed wrong, and only one of the oscillator terminals was connected, I fine this when I was reviewing the oscillator circuit, because the RC circuit didn't look right, we has preveusly change the design of the board and we incorporate a surface-mount Oscillator on the new design.

I want to thanks every one of you for the advises that I received  

Thanks again.
 

On Friday, November 17, 2017 at 4:51:43 PM UTC-5, Robert Reese wrote:
Sergio -- how you are checking the 485TX/485RX PCB signals on a scope when the temperature is above 160F? Do you have a temp chamber with the ability to bring signals from the PCB out for external monitoring?

I agree with Bryan's suggestions -- I have experienced framing errors at normal temps for some higher baud rates when trying to use BRGH =1. I have never had problems with  BRGH =0.

And, I agree with Matt Stowell -- at this point, I think the problem may be with some component other than the PIC24.  What about U5, the LTC485 RS485 transceiver?  Are you using the extended range temperature version of this device? The normal range for this tops out at 70C (158 F).

Bob Reese



On Fri, Nov 17, 2017 at 11:11 AM, Sergio Galmez <ke...@hotmail.com> wrote:

Yes, I did check the Rx/Tx on the scope, the length of the message and the timing are correct

--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-c-book+unsub...@googlegroups.com.
To post to this group, send email to pic24-assemb...@googlegroups.com.

Matt Stowell

unread,
Dec 4, 2018, 10:34:14 PM12/4/18
to pic24-assemb...@googlegroups.com
Hi Sergio,

Thanks for closing the loop on the discussion.  Glad you solved the issue!

-Matt Sowell

On Tue, Dec 4, 2018 at 8:01 AM Sergio Galmez <ke...@hotmail.com> wrote:
Sorry for take me so long to get back to this issue, I was really busy with other projects.

I did resolve this problem when I was testing and following the advice received here. I wanted to get back to explain how i got this fixed, since I didn't want to leave an open topic.
At the end I fine that the path of the crystal oscillator where designed wrong, and only one of the oscillator terminals was connected, I fine this when I was reviewing the oscillator circuit, because the RC circuit didn't look right, we has preveusly change the design of the board and we incorporate a surface-mount Oscillator on the new design.

I want to thanks every one of you for the advises that I received  

Thanks again.
 

On Friday, November 17, 2017 at 4:51:43 PM UTC-5, Robert Reese wrote:
Sergio -- how you are checking the 485TX/485RX PCB signals on a scope when the temperature is above 160F? Do you have a temp chamber with the ability to bring signals from the PCB out for external monitoring?

I agree with Bryan's suggestions -- I have experienced framing errors at normal temps for some higher baud rates when trying to use BRGH =1. I have never had problems with  BRGH =0.

And, I agree with Matt Stowell -- at this point, I think the problem may be with some component other than the PIC24.  What about U5, the LTC485 RS485 transceiver?  Are you using the extended range temperature version of this device? The normal range for this tops out at 70C (158 F).

Bob Reese



On Fri, Nov 17, 2017 at 11:11 AM, Sergio Galmez <ke...@hotmail.com> wrote:

Yes, I did check the Rx/Tx on the scope, the length of the message and the timing are correct

--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-...@googlegroups.com.

To post to this group, send email to pic24-assemb...@googlegroups.com.
Visit this group at https://groups.google.com/group/pic24-assembly-to-c-book.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "PIC24 Assembly-to-C Book" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pic24-assembly-to-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages