Can't set 38400 baud @ 48Mhz


Closed Thread
Results 1 to 39 of 39

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130

    Default Can't set 38400 baud @ 48Mhz

    Hi all,
    I'm trying unsuccessfully to get an 18f4550 to run 38400 baud when set as follows:

    Define OSC 48
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 77 ' 38400 Baud @ 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    I'm using a 20Mhz crystal, Picbasic Pro 2.46, Mpasm 7.52. When it compiles it doesn't like the PBPPIC18.lib, it says the argument is out of range and only the least significant bits are used. If I change the OSC define to 20 it works fine, but then I can't use USB.

    Thanks!

    Jerry.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Do your config lines look like this?
    Code:
    @   __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L  
    @   __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    Added: I compiled it here, added an HSEROUT statement, and didn't get an error.

    PBP 2.46 MPASM 5.06

    DT

  3. #3
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by b1arrk5 View Post
    Hi all,
    I'm trying unsuccessfully to get an 18f4550 to run 38400 baud when set as follows:

    Define OSC 48
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 77 ' 38400 Baud @ 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    I'm using a 20Mhz crystal, Picbasic Pro 2.46, Mpasm 7.52. When it compiles it doesn't like the PBPPIC18.lib, it says the argument is out of range and only the least significant bits are used. If I change the OSC define to 20 it works fine, but then I can't use USB.

    Thanks!

    Jerry.
    Have you tried HSER_BAUD 38400 instead?
    Maybe SEROUT2 with a mode number of 6?
    At least post the offending part of your .asm file so we can see which variables are causing the pain...

  4. #4
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130

    Default Maybe We're getting closer!

    Darrel,

    I added your config lines, and commented out the lines in the 18f4550.inc file to do away with the overwrite errors, now I'm down to just these two,

    Warning[202] \PBPPIC18.LIB 7695:argument out of range. least significant bits used.
    Error[113]c:\pbp\usb18\march3.asm 177:Symbol not previously defined(_FCMEN_OFF_1H)

    Skimask,
    I tried the HSER_BAUD 38400, and it compiles fine, but the serial baud rate is not 38400. I have a program that is working great on an 16f877, and the hardware that it interfaces with will only work at 38400. If I stick the '877 in the same board it works perfectly, when I go back to the '4550 nothing happens, and when I tried a monitor program on another PC it shows garbage. I read in the manual that you won't always get an error if your define is incorrect, the compiler just ignores it. I suspect that I am overlooking something stupidly simple, but I'd rather look dumb and learn the answer than be dumb forever.

    I ran out of memory on the '877, and I thought going to the '4550 and getting a USB port might be real handy later on.

    Thanks guys for all your help. Have a great weekend!

    Jerry.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    >> Error[113]c:\pbp\usb18\march3.asm 177:Symbol not previously defined(_FCMEN_OFF_1H)

    You have an oldish version of MPASM. Change it to _FCMEM_OFF_1H. It was changed to FCMEN in the latest version.

    If the other error is still there, you'll need to look in the .LST file, and search for [202].

    DT

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    how about using the whole set bellow
    Code:
        asm
        __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L  
    
        __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H 
    
        __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L   
        __CONFIG    _CONFIG2H, _WDT_OFF_2H 
        __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H 
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L  & _XINST_OFF_4L & _DEBUG_OFF_4L 
        endasm
    Sure this will not solve the warning 202...

    I've tested it here... everything is clean.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130

    Default Maybe?

    Thanks Darrel and Steve. No change. I did the online update yesterday for MicroCode Studio Plus, and I updated MPLAB. However after reading Darrel's reply I looked and found that it was using MPASM 3.x! I manually set it to use 5.06.4 (MPLAB is version 7.51) I found the error in the .lst file, but I don't know enough assembler to tell anything except that nowhere can I find an spbrgh register mentioned. If I am reading the datasheet correctly, when I enable the 16 bit baudrate generator I should have to set spbrgh (High byte) = 1, and spbrg (Low byte) = 56. I got these values from Steve's calculator program, which has never led me wrong! I did see on Bruce's website that PBP version 2.47 has some kind of fix for 18f devices to use spbrgh, so I think I'll give MELABS a call and inquire. I don't mind spending the money for the upgrade, I just hate waiting a week for UPS! Just as an after thought, did either of you verify that you were actually sending out serial at 38400? I can get it to compile fine using Skimask's suggestion, but the output is not 38400, even though there are no errors.
    Thanks again!

    Jerry.

  8. #8
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130

    Default That got me too!

    Hi Darrel,
    It took me a bit to figure out as well, until Steve mentioned using the buttons on the bottom copy to the clipboard. When I did that it showed the 1 and 56. Putting 312 into my scientific calculator and converting to binary showed me that MultiCalc was correct.

    Isn't still the middle of the night where you are?


    Thanks for all your help,


    Jerry.

  9. #9
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130

    Default Never mind!

    Darrel,
    I thought you answered this morning, I saw the 9 oclock on the post, and it's just after 9 am here now. I need new glasses!

    Jerry.

  10. #10
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130

    Default Patches, we don't need no stinkin' patches!

    Hi guys,
    Yes, I did download and install the patch from the MeLabs site for 2.46, and it said it installed ok. I tried that, and I downloaded the beta loader software for my USB programmer, also MeLabs, before I posted on the forum because I thought that perhaps my .inc file was too old to have the spbrgh register in it or something. I also downloaded the upgrade for MicroCode Studio Plus.
    Thanks,

    Jerry.
    If your oscilloscope costs more than your car...

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Auto Baud Rate Detection
    By mytekcontrols in forum Serial
    Replies: 10
    Last Post: - 31st October 2005, 02:17
  3. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31
  4. help
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th February 2005, 20:42
  5. Need once your help one please
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 9th February 2005, 20:33

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts