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

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

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

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

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

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

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

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

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

Similar Threads

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