Jump to content
 
  • 0

Change Baud Rate from 9600 to 19200 PIC16F1718 using MPLAB


Marco
 Share

Question

I have a program in MPLAB that works correctly when sending messages through the LIN system at a baud rate of 9600, but when I change it to 19200 it does not come out. I am using the MPLAB Code configurator V4 tool and in the window for Eusart I put the 19200 which are the Baud Rates to which I want to transfer.

 

It is expected to know the values in the eusart.c file of SP1BRGL and SP1BRGH for the Baud Rate corresponding to 19200.
Tried with SP1BRGL values of 0x40,0X65,0xFE, 0x3B, 0x3D keeping SP1BRGH at 0x00.

Also in the application in the Registers of the variables of Sp1BRGL and SP1BRGH so that they correspond to a Baud Rate of 19200.

For the calculation, the table for pic16 was used, it is expected in high transfer speed with a 16 Mhz oscillator an SPBRG of 51 but it still did not work.

I do not know what I am doing wrong, to read the data I am using a LIN analyzer tool and everything works at a Baud rate of 9600 but I take it to be 19600 for the application.

 

 

1.PNG

2.PNG

3.png

4.png

5.png

5.jpg

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
  • Member

I apologize for not responding sooner and welcome to microforum.

Are you able to measure the actual baudrate produced by your settings?

If you are getting data out that is more than 5% away from 19200, then the issue can be traced to the accuracy of the internal oscillator and you have a few options.

1) take advantage of the autobaud feature.  This feature was added specifically for LIN so it is compatible with the typical LIN bus framing.
2) use the OSCTUNE feature (if available) to fine tone the FOSC until you achieve the required baud rate.  Note, this value could be different for every device.
3) adjust the SPBRG values a little bit to compensate for the real oscillator frequency.
4) use an external crystal to create an FOSC at the required value.

Good luck

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

 


×
×
  • Create New...