CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

18F25k50 baud rate 38400 not working

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mvme5100



Joined: 10 Nov 2016
Posts: 6

View user's profile Send private message

18F25k50 baud rate 38400 not working
PostPosted: Sat Dec 11, 2021 5:52 am     Reply with quote

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: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Dec 11, 2021 6:16 am     Reply with quote

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: 19497

View user's profile Send private message

PostPosted: Sat Dec 11, 2021 8:34 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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