Can't set 38400 baud @ 48Mhz


Closed Thread
Results 1 to 39 of 39
  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
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by b1arrk5 View Post
    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.
    It worked for me, but maybe my crystal (10mhz using the 4xPLL) was being pulled off just far enough in the right direction to get the baud rate correct. The divider used for SERIN/SEROUT2 (1,000,000 / baud - 20) gets a bit low numerically in this case, even though the 'formula' says it's 'only' 4%+ off the mark.
    And even though PBP 2.47 says it has a couple of extra defines and fixes specifically for PIC18Fxxxx and a couple of HSER fixes, surely you can set the bits in the middle of the program instead of letting PBP do it for you at the beginning...or something along those lines. Maybe PBP sets all the bits the first you use the command, so, send out a 'dummy' command, then try setting the bits manually after that? Who knows...might work...

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

    Default

    Yes the calc is good and PicMultiCalc.. of course

    In fact i've tested with your crystal speed, my config fuses above, the DEFINEs generated by the PicMultiCalc, and add a HSEROUT ["Joyeux Noel et Bonne Année!!!",13,10] to do the test... all fine

    So, OR your device programmer don't program the config fuse properly OR your crystal is pretty bad (2.00 MHZ instead of 20.00 MHz) OR your PIC is bad or Or the supply line is messy OR everything above + bad lucks (bad capacitor or bad value around the crystal)

    I've tested with a USB to serial converter... still working.

    If you want to use the EUSART, use the PicMultiCalc EUSART then paste the setting generated in your code. It have to work as well.

    I don't know about the 18F fixes, but you could still write directly to the register instead of using DEFINEs to see if it solve some part of the problem.

    we could still compile the code and send you the .HEX file. So you will know if it's related to V2.46... or back to the keyboard Just kidding!

    Do you erase the PIC before programming it?
    Last edited by mister_e; - 4th March 2007 at 22:59.
    Steve

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

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

    Wink Still typing!

    Thanks guys. I have ruled out my programmer, crystal, etc. due to the fact that I can program and run Steve's USB demo program no problem. In fact what started all of this is that I tried to add a serial port connection to his program to see if I could extract data via the serial port, and put it out the USB port. I did copy and paste from Steve's Pic Multicalc program. If I set my OSC define to 20 Mhz, and set up the programmer for HS instead of HSPLL, I can get 38400 out, and if I insert a 16f877 into the same board I can get 38400 out. It's just when I set the OSC to 48 Mhz that I get the argument out of range warning. I'm using a MELABS Labxusb board, in fact I have two of them, and I have tried both. I'm using MELABS USB serial programmer, I have the latest patches installed from their website, I tried the USB programmer Beta version as well. I even tried installing all of the software on a different PC. What is weird is that I can burn Steve's USB demo ok, and I can do the USB mouse demo no problem, or like I said, I can drop down to 20Mhz ok. I'm still not ruling out my doing something stupid............

    Keep warm in Montreal and North Dakota. It's getting colder here in Pennsylvania, but Saint Patty's day is coming!

    Many thanks again,
    Jerry.

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

    Default

    it's not too cold in here, but we had 50-60 cm of snow since thursday night, and we're suppose to have 10-20 more tomorrow or tuesday Bah, could be worst!

    You have a strange problem, i've attach a working .HEX code: USART, 38400 Bauds, 20Mhz crystal, send string loop. nothing fancy.

    Now if you dump it directly to your PIC and it's not working... it's because of the Melabs Programmer. Obviously, if it's working, it's down to V2.46... which may explain this weird warning 202... who knows?
    Attached Files Attached Files
    Steve

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

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

    Default It's working!

    Steve,

    Como ca va? Tres bien! Forgive my spelling, but your hex file loaded and works perfectly! This means that I have my programmer etc. set correctly. Just two quick questions then; a) are you using PBP 2.47? b) would you please try adding this to your USB demo program and see what happens. I placed these right after the Define OSC 48 line.

    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $24 ' Enable transmit, BRGH = 1
    SPBRG = 56 ' 38400 Baud @ -0.16%
    SPBRGH = 1
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator

    cren var rcsta.4
    hserout ["Yes we have no bananas!",13]

    When I take these lines back out the program compiles fine. The good news is that I've almost memorized the 18f4550 datasheet this weekend! I also tried adding this;
    asm
    mov w,1
    movlw spbrgh
    mov w,56
    movlw spbrg
    endasm
    right after the _config portion of the program, but no luck. I'm don't do assembler, but I read Myke Predko's book, and can follow along.

    Thanks again, and don't shovel too much snow!

    Jerry.

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

    Default

    Maybe I'm reading the PicMultiCalc wrong but...

    With BRGH = 1 (TXSTA = $24), and BRG16 = 1 (BAUDCON.3)

    Don't you need SPBRG = 312

    Attached Images Attached Images  
    DT

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

    Default

    Doh!, nevermind.

    Got confused with SPBR<G:H> notation.

    Lowbyte = 56
    Highbyte = 1

    DT

  15. #15
    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.

  16. #16
    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.

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

    Default

    Quote Originally Posted by b1arrk5 View Post
    Como ca va? Tres bien! Forgive my spelling,
    Ca va très bien you spelling is not that bad. Como=Comment
    but your hex file loaded and works perfectly! This means that I have my programmer etc. set correctly.
    Woooohooo!
    a) are you using PBP 2.47? b) would you please try adding this to your USB demo program and see what happens. I placed these right after the Define OSC 48 line.

    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $24 ' Enable transmit, BRGH = 1
    SPBRG = 56 ' 38400 Baud @ -0.16%
    SPBRGH = 1
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator

    cren var rcsta.4
    hserout ["Yes we have no bananas!",13]
    Yes i use PBP 2.47, and your lines will work no problem.

    Thanks again, and don't shovel too much snow!
    i'll try


    EDIT: i'll change the PicMultiCalc display stuff.. it's really simple and i agree, it will be easier to read.
    Steve

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

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

    Smile Merci!

    I called MeLabs this morning as soon as they opened, ordered the upgrade, and they shipped it this afternoon. Thanks for all your help. I'm curious though that Darrel got it to compile ok with 2.46, but maybe it has to do with the temperature. I think you and I should go to California and investigate!
    Thanks to all of you for your kind assistance.

    Jerry.

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

    Default

    You're welcome. in meantime, i've did the promised change to the PicMultiCalc

    You can download it at the usual place
    http://www.mister-e.org/pages/utilitiespag.html
    Attached Images Attached Images  
    Steve

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

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

    Default

    b1arrk,

    It's good to have the upgrade.

    But for future reference, I'd still like to figure out what's going on. And I'm still not sure it will solve your problem.

    Can you go back to the .LST file again? Search for [202], and post the 5 or 6 lines following the error.

    DT

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

    Question I would love to know.

    Hi Darrel,

    Here are the lines from the .LST file. I hope that you find something useful here. It's great that we can come here and get professional level assistance from guys like you, Skimask and Steve, especially on the weekends when a lot of us have more time to work on our projects, so if I can provide any additional information please let me know.
    code
    Warning[202]: Argument out of range. Least significant bits used.
    000498 0E38 07695 movlw HSER_SPBRG
    00049A 6EAF 07696 movwf SPBRG ; Set baud rate generator reg
    00049C 0E20 07697 movlw HSER_TXSTA
    00049E 6EAC 07698 movwf TXSTA ; Set transmit control reg
    0004A0 0E90 07699 movlw HSER_RCSTA
    0004A2 6EAB 07700 movwf RCSTA ; Set receive control reg
    07723 LIST
    0004A4 07724 main
    0004A4 EF1F F006 00012 goto MAINPROG
    00013 include "USB18.INC"
    00001 ; MUID = Microchip USB Class ID
    00002 ; Used to identify which of the USB classes owns the current
    00003 ; session of control transfer over EP0
    00004 #define MUID_NULL 0
    00005 #define MUID_USB9 1
    00006 #define MUID_HID 2
    00007 #define MUID_CDC 3
    00008 #define MUID_MSD 4
    00009
    00010 ; Buffer Descriptor Status Register Initialization Parameters
    00011 #define _BSTALL 0x04 ; Buffer Stall enable
    00012 #define _DTSEN 0x08 ; Data Toggle Synch enable
    00013 #define _INCDIS 0x10 ; Address increment disable
    MPASM 5.06.4 MARCH3~1.ASM 3-4-2007 18:59:54 PAGE 23
    /code
    I don't pretend to be an assembler wiz, I did take a course years ago in 6800 and 68000, but I didn't use it for more than ten years, and of course the Pic is a little different. But I don't see any mention of SPBRGH anywhere here.
    Once again, thanks for all your effort, and I look forward to hearing what you figure out.

    Jerry.

  22. #22
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by b1arrk5 View Post
    (It's great that we can come here and get professional level assistance from guys like you, Skimask)

    Warning[202]: Argument out of range. Least significant bits used.
    000498 0E38 07695 movlw HSER_SPBRG
    00049A 6EAF 07696 movwf SPBRG ; Set baud rate generator reg
    00049C 0E20 07697 movlw HSER_TXSTA
    00049E 6EAC 07698 movwf TXSTA ; Set transmit control reg
    0004A0 0E90 07699 movlw HSER_RCSTA
    0004A2 6EAB 07700 movwf RCSTA ; Set receive control reg

    Jerry.
    Wow! I ain't never been called no prefeshunol befowere...Gawllleee

    Anyways...yep, right there at the top. The compiler isn't handling SPBRGH correctly, basically putting a value over 256 into a byte. However, I suspect that if you tell the compiler you want a baud rate of 13,636 (8 bit async, brg16 = 0, brgh = 0, 48mhz Fosc, etc.etc according to the datasheet should give you 56 in the SPBRGH, which should get automatically set according to the HSER defines), and then manually set BRGH high later on, it'll an up at 38400 baud. I would think this is something you should've been able to do manually, but I could be wrong...

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

    Default

    i suspect a asm math overflow, but can't reproduce it here... and... HSER_BAUD is not define so... i'm lost

    Even worst.. if does the same thing even by writing to the USART register ???

    what happen if you use only the CONFIG fuse, DEFINE OSC AND HSER DEFINEs?

    edit: OK only by writing to the REGISTER, you'll have this error once you add a HSEROUT line, but it fix the problem when you use the DEFINEs as generated by the PicMulticalc as bellow
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 56  ' 38400 Baud @ 48MHz, -0.16%
    SPBRGH = 1
    BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
    So the DEFINEs have to be there IF you're using HSEROUT/HSERIN... just because PBP try to load HSER_SPBRG and everything else
    simple code
    Code:
    DEFINE OSC 48
    RCSTA = $90   ' Enable serial port & continuous receive
    TXSTA = $24   ' Enable transmit, BRGH = 1
    SPBRG = 56    ' 38400 Baud @ 48MHz, -0.16%
    SPBRGH = 1
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
    
    HSEROUT ["HELLO"]
    and it's .LST around warning 202
    Code:
    Warning[202]: Argument out of range.  Least significant bits used.
    000018 0E38           07668         movlw   HSER_SPBRG
    00001A 6EAF           07669         movwf   SPBRG           ; Set baud rate generator reg
                          07670     ifdef HSER_SPBRGH
                          07671       ifdef SPBRGH
                          07672         movlw   HSER_SPBRGH
                          07673         movwf   SPBRGH          ; Set baud rate generator reg high
                          07674       endif
                          07675     endif
    00001C 0E20           07676         movlw   HSER_TXSTA
    00001E 6EAC           07677         movwf   TXSTA           ; Set transmit control reg
    000020 0E90           07678         movlw   HSER_RCSTA
    000022 6EAB           07679         movwf   RCSTA           ; Set receive control reg
    INTERESTING !!!! HSER_SPBRGH is not even listed in the new PBP manual!!!
    Last edited by mister_e; - 7th March 2007 at 04:49.
    Steve

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

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

    Default

    Yup, you got it Steve.

    Without the Define's, PBP defaults to 2400 baud and BRGH=0, which is too low for 48mhz.

    But, in the first post, the defines were there. And those defines compile just fine.

    So confused.

    DT

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

    Default

    yeah, weird... maybe a beta V2.46? who knows
    12:14 here so
    Steve

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

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

    Default

    Beta 2.46

    DT

  27. #27
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Beta 2.46
    You laugh...but for some reason I think I might have a one-off version of 2.46. I got it a couple of months after it came out. Then noticed that patch awhile after that, still haven't been able to get that applied successfully. Some of the PBP INC files are labelled 2.45, some much earlier than that (but then again, no need to waste time by renaming stuff if you didn't do anything to it right?). I emailed Jeff about it awhile back, he sent me an email back, I never did get around to sending a copy of my registration, etc. to get a new CD and he mentioned 2.47 was on it's way out, so I held off...
    I'm wondering if this 2.46 isn't my problem with the SPI on the '4620, worked fine on the '452, never could get it to work on the '4620. Maybe 2.47 will fix that too, maybe Microchip will someday publish another errata...

    At any rate... I still wonder if the original poster could easily get around this whole problem by setting the register values manually instead of relying on the compiler to handle it automatically...

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

    Default

    Woooaa, there's an Idea.

    Jerry,

    Have you run the Patch for 2.46 yet?
    http://www.melabs.com/support/patches.htm

    I did a long time ago, forgot all about it.

    Good thought skimask.

    P.S. The 2.47 upgrade will fix that if you didn't.

    P.P.S. The patch is a PITA. because if you have modified the .INC files (like we all do for the configs), it won't run, until you undo the changes. If you haven't done it yet, just wait for 2.47. It'll save you a few hours of horror.

    DT

  29. #29
    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...

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

    Default

    Quote Originally Posted by Darrel Taylor View Post
    P.P.S. The patch is a PITA.
    mmm PITA

    Steve

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

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

    Wink Solution!

    Hi guys,

    After speaking with the nice folks at MeLabs I have the following explanation, the warning is due to the fact that PicBasic defaults to 2400 baud, and I had the oscillator set to 48Mhz, which it can't do with the high speed baud generator register set. I was close, I could get it to compile without the warning, but the baudrate wasn't right. The following code works perfectly now;

    BAUDCON.3 = 1 'SETUP FOR HIGH SPEED.
    DEFINE HSER_RCSTA 90H
    DEFINE HSER_TXSTA 24H 'HIGH SPEED MODE BAUD RATE GENERATOR
    DEFINE HSER_BAUD 38400
    DEFINE HSER_SPBRG 38H '38400 BAUD *** THIS WORKS! ***
    DEFINE HSER_SPBRGH 01H

    Thanks,

    Jerry.

    Thanks for all your help!
    If your oscilloscope costs more than your car...

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

    Default

    Isn't that what Steve and I said in Post #24 and 23?

    DT

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

    Smile Exactly!

    I'm sorry, I should have made it more clear, that was why I posted the 'solution,' so that you and Steve would know that you were indeed right! More importantly, you guys were available and willing to help out on the weekend, which is when I have uninterrupted time to work, as opposed to during the week when the phone rings incessantly. Have a great weekend!

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

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

    Default

    Oh, woops. Now I get it.

    Woohoo.

    DT

  35. #35

    Default

    Hi there
    Can someone please help i am trying to upgrage one of my projects to a 18F4550 but it is turning into a nigtmare, for some reason i can not get my serial port to work
    Any help would be appreciated

    ps I have downloaded the patch for 2.46 but it seems not to help

    my 18F4550.inc file
    Code:
      NOLIST
        ifdef PM_USED
            LIST
            "Error: PM does not support this device.  Use MPASM."
            NOLIST
        else
            LIST
            LIST p = 18F4550, r = dec, w = -311, w = -230, f = inhx32
            INCLUDE "P18F4550.INC"	; MPASM  Header
            __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 
           
            
            NOLIST
        endif
            LIST
    EEPROM_START	EQU	0F00000h
    BLOCK_SIZE	EQU	32
    And my setup i am running a 48M cristal
    Code:
    '*Serial port Setup 3800 8N1*
    BAUDCON.3 = 1 'SETUP FOR HIGH SPEED.
    DEFINE HSER_RCSTA 90H
    DEFINE HSER_TXSTA 24H 'HIGH SPEED MODE BAUD RATE GENERATOR
    DEFINE HSER_BAUD 38400
    DEFINE HSER_SPBRG 77 ' 38400 Bauds
    DEFINE HSER_CLROERR 1

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

    Default

    And my setup i am running a 48M cristal
    Ummm, you mean you are running a 20mhz crystal, with DEFINE OSC 48?

    I Hope.

    DT

  37. #37

    Default

    No, 48M cristal with define osc 48

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

    Default

    The highest crystal frequency you can use on an 18F4550 is 25Mhz (24 if using the PLL).

    If it's a TTL Oscillator, then it's possible to put 48Mhz directly into the PIC with EC mode. But XT or HS modes cannot drive a 48Mhz crystal.

    The configs you showed are set up for a 20Mhz crystal.

    DT

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

    Default

    Also, SPBRG 77 is the value if SPBRGH = 0, since you have SPBRGH set to 1, then SPBRG should be 56.

    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