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

    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.

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

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

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

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

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

    Default

    Beta 2.46

    DT

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

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