|
|
View previous topic :: View next topic |
Author |
Message |
mvme5100
Joined: 10 Nov 2016 Posts: 6
|
18F25k50 baud rate 38400 not working |
Posted: Sat Dec 11, 2021 5:52 am |
|
|
Hello,
Asking for help with the correct #use and #fuse settings for PIC18F25k50 UART using 38400 baud rate.
I'm using PIC18F25k50 with 16Mhz crystal.
I tried this and some other settings without success:
Code: | #include <18F25k50.h>
#Device ADC=10
#fuses NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP,INTRC_IO//,NOMCLR
#use delay(clock=16000000)
#use rs232(baud = 38400, xmit=PIN_C6, rcv = PIN_C7, ERRORS) //, stream=STREAM_USER_UART, timeout=200) |
Thank you |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Sat Dec 11, 2021 6:16 am |
|
|
need more information....
1) which compiler version ?
2) does a 1Hz flashing LED work properly ?
3) does the RS-232 work at say 9600 baud ?
4) what is the other RS-232 device ?
5) do you have proper TTL<>RS232 interface chips(aka MAX232) ?
6) do you have a ground between the PIC and other device ?
7) do the other device work with another computer ?
8) what is the VDD supply for the PIC ?
9) oops ! just saw this...
Quote: | #fuses NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP,INTRC_IO//,NOMCLR |
INTRC_IO means use the INTernal RC oscillator as the PIC clock source, but you say you have a 16MHz crystal !! If using a real xtal, you'll need to change the fuse and be sure to have 2 caps for the xtal as well.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19511
|
|
Posted: Sat Dec 11, 2021 8:34 am |
|
|
The key is as Jay has spotted, that your clock setup is wrong.
Code: |
//For a 16Mhz crystal
#include <18LF25K50.h>
#device ADC=10
#FUSES NOWDT, NOLVP, BROWNOUT, PUT, NOPROTECT
#use delay(crystal=16MHz)
#use rs232(baud = 38400, xmit=PIN_C6, rcv = PIN_C7, ERRORS)
void main()
{
while(TRUE)
{
}
}
|
Or for the internal oscillator _at 16MHz_:
Code: |
#include <18LF25K50.h>
#device ADC=10
#FUSES NOWDT, NOLVP, BROWNOUT, PUT, NOPROTECT
#use delay(INTERNAL=16MHz)
#use rs232(baud = 38400, xmit=PIN_C6, rcv = PIN_C7, ERRORS)
void main()
{
while(TRUE)
{
}
}
|
By default, the internal oscillator branch, selects the primary oscillator
route, with the CPUDIV fuses set to 00. This gives /2. So your chip will
be running at 8Mhz, not 16MHz.
Using the keyword 'CLOCK' says 'this is the frequency I am running'.
Problem is your fuse settings do not give this frequency.
Use the keywords 'INTERNAL' or 'CRYSTAL' to tell the compiler to setup
the clock source, divisions and PLL to support the specified speed. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|