• AVR Freaks

Hot!Mismatched receive data using UART on dsPIC33CH512MP505

Page: < 12 Showing page 2 of 2
Author
du00000001
Just Some Member
  • Total Posts : 4071
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Mismatched receive data using UART on dsPIC33CH512MP505 2020/05/15 06:34:38 (permalink)
0
Re 2400 Bd configuration:
MCC shows a baudrate error of -0.080. Which translates to 8 %!
The only small wonder is that you sometimes receive the MSBit not set  :(
UART baudrate errors should never exceed 5 % (all tolerances included), although values up to 2.5 % are preferred.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#21
Geri
Junior Member
  • Total Posts : 107
  • Reward points : 0
  • Joined: 2005/06/30 01:06:49
  • Location: Austria
  • Status: offline
Re: Mismatched receive data using UART on dsPIC33CH512MP505 2020/05/15 06:54:00 (permalink)
0
Hello
 
@ric: I set the transmitter 2 stop bits
@Gort2015 & du000x1: I changed the baud rate to 600 bit/s so there is only 2% error
 
 
I checked the baud rate with the oscilloscope. I measured 597 bits/s
 
Best regards
Geri
 
#22
du00000001
Just Some Member
  • Total Posts : 4071
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Mismatched receive data using UART on dsPIC33CH512MP505 2020/05/15 07:00:31 (permalink)
0
Geri
Hello
 
@ric: I set the transmitter 2 stop bits
@Gort2015 & du000x1: I changed the baud rate to 600 bit/s so there is only 2% error
 
 
I checked the baud rate with the oscilloscope. I measured 597 bits/s
 
Best regards
Geri



Does it work now? (BTW: 597 Bd is more like 0.5 %).
Does MCC say 2 % ? If so, you'd better measure the dsPIC's output - not the input.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#23
LdB_ECM
Super Member
  • Total Posts : 456
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: Mismatched receive data using UART on dsPIC33CH512MP505 2020/05/15 07:19:56 (permalink)
0
Can I have another guess, I am pretty good at playing this game as I have regularly have interns who do stupid things :-)
 
The code shows UART1 is setup to 115200 and it is fully setup with interrupts ... so can I ask are the pins actually connected or if not in use got pullup/downs ( So RX and TX)?
#24
JPortici
Super Member
  • Total Posts : 1241
  • Reward points : 0
  • Joined: 2012/11/17 06:27:45
  • Location: Grappaland
  • Status: offline
Re: Mismatched receive data using UART on dsPIC33CH512MP505 2020/05/15 07:44:08 (permalink)
5 (1)
jesus christ why use MCC?
 
using board's external clock at 8MHz
  //Set up system clock at 24 MHz. First switch to FRC
  INTCON2bits.GIE = 0;
  __builtin_write_OSCCONH(0x0);
  __builtin_write_OSCCONL(OSCCON | 0x01);
  // Wait for Clock switch to occur
  while(OSCCONbits.COSC != OSCCONbits.NOSC);

  //Set up PLL parameters
  CLKDIVbits.PLLPRE = 0;      //Input frequency is 8MHz
  PLLFBD = 60;                //FVCO is 384 MHz
  PLLDIVbits.POST1DIV = 5;
  PLLDIVbits.POST2DIV = 2;    //PLL Output is 48MHz, System Clock will be 24MHz

  //Perform Clock Switch
  __builtin_write_OSCCONH(0x3);
  __builtin_write_OSCCONL(OSCCON | 0x1);
  INTCON2bits.GIE = 1;

 
FCY is defined as 12000000UL
  U1MODE = 0;
  U1MODEbits.BRGH = 1;
  U1MODEbits.UTXEN = 1;     //Enable Transmitter
  U1MODEbits.URXEN = 1;     //Enable Receiver

  U1MODEH = 0;              //UART in Legacy Mode, BRG Clofk is Fp
  U1STAH = 0;
  U1BRGH = 0;
  U1BRG = (FCY / (4 * 19200ul)) - 1;

  U1MODEbits.UARTEN = 1;

 
I don't have any conclusive test BUT i noticed on a dsPIC33CK that there were errors in start/stop bit lenght if BRGH = 0 at many baud rates
#25
Geri
Junior Member
  • Total Posts : 107
  • Reward points : 0
  • Joined: 2005/06/30 01:06:49
  • Location: Austria
  • Status: offline
Re: Mismatched receive data using UART on dsPIC33CH512MP505 2020/05/15 08:48:15 (permalink)
0
Hello
 
Thank you all for your hints!
 
@du000x1: I tested with 600 Baud but same problem.
I set baud rate to 9600 bit/s:
I also measured the baud rate from PC side and got 105 us/bit = 9523 bit/s
I measured baud rate, generated by dsPIC and got 110 us/bit = 9009 bit/s
so it is 5,7% :(
 
I switched to PLL mode but same result.
 
€Ldb_ECM: 
"The code shows UART1 is setup to 115200 and it is fully setup with interrupts ... so can I ask are the pins actually connected or if not in use got pullup/downs ( So RX and TX)?"
 
Same results if I do not use interrupts, lower frequencies. I directly measured the input signal on the IO-Pin and it ist good. No internal Pullups and Pulldowns are activated.
 
@JPortici:
"jesus christ why use MCC?" This is the first time I am using this tool but I used it configurators from outher manufactures and got working results.
 
I tried your code but the application stucks in the while loop.
 
Best regards
Gerhard
 
 
 
 
 
 

Attached Image(s)

#26
du00000001
Just Some Member
  • Total Posts : 4071
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: Mismatched receive data using UART on dsPIC33CH512MP505 2020/05/15 08:59:57 (permalink)
5 (1)
@ Geri
I think I'm giving up now. This seems to be a severe case of PEBKAC,
LdB_ECM
... I have regularly have interns who do stupid things ...

which can't be cured without direct personal intervention.
 
A lasst recommendation: Change less frequent virtually all and everything!
Stay with one configuration (unless it's completely impossible to make it work - like > 2.5 % baud rate mismatches)  and work hard to make it work.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#27
Geri
Junior Member
  • Total Posts : 107
  • Reward points : 0
  • Joined: 2005/06/30 01:06:49
  • Location: Austria
  • Status: offline
Re: Mismatched receive data using UART on dsPIC33CH512MP505 2020/05/15 09:02:12 (permalink)
0
Yes, your hint was right.
I just set baud rate manually and it seems to work
#28
Geri
Junior Member
  • Total Posts : 107
  • Reward points : 0
  • Joined: 2005/06/30 01:06:49
  • Location: Austria
  • Status: offline
Re: Mismatched receive data using UART on dsPIC33CH512MP505 2020/05/15 09:06:34 (permalink)
5 (1)
I assumed the MCC tool creates code that can be used directly. As the data that arrived to the PC were fine, I guessed that the baud rate is good. So I checked the output baud rate once as you said it today:) Thank you for the hin!
#29
Page: < 12 Showing page 2 of 2
Jump to:
© 2021 APG vNext Commercial Version 4.5