PDA

View Full Version : Can't set 38400 baud @ 48Mhz



b1arrk5
- 4th March 2007, 03:48
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.

Darrel Taylor
- 4th March 2007, 04:02
Do your config lines look like this?
@ __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
<br>

skimask
- 4th March 2007, 04:03
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...

b1arrk5
- 4th March 2007, 17:03
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.

Darrel Taylor
- 4th March 2007, 17:47
>> 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].
<br>

mister_e
- 4th March 2007, 18:09
how about using the whole set bellow


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.

b1arrk5
- 4th March 2007, 22:59
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.

skimask
- 4th March 2007, 23:16
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...

mister_e
- 4th March 2007, 23:51
Yes the calc is good and PicMultiCalc.. of course :D

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 :D Just kidding!

Do you erase the PIC before programming it?

b1arrk5
- 5th March 2007, 00:19
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.

mister_e
- 5th March 2007, 00:39
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 :eek: 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?

b1arrk5
- 5th March 2007, 01:24
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.

Darrel Taylor
- 5th March 2007, 03:18
Maybe I'm reading the PicMultiCalc wrong but...

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

Don't you need SPBRG = 312

<img src=http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1445&stc=1&d=1173060943>

Darrel Taylor
- 5th March 2007, 03:26
Doh!, nevermind.

Got confused with SPBR&lt;G:H> notation.

Lowbyte = 56
Highbyte = 1

:o

b1arrk5
- 5th March 2007, 15:15
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.

b1arrk5
- 5th March 2007, 15:17
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.

mister_e
- 6th March 2007, 00:29
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!

:eek: i'll try ;)


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

b1arrk5
- 6th March 2007, 00:48
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.

mister_e
- 6th March 2007, 01:47
You're welcome. in meantime, i've did the promised change to the PicMultiCalc

<img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1448&stc=1&d=1173141909">

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

Darrel Taylor
- 6th March 2007, 03:22
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.
<br>

b1arrk5
- 7th March 2007, 00:33
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.

skimask
- 7th March 2007, 01:09
(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...

mister_e
- 7th March 2007, 05:36
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


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


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


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

Darrel Taylor
- 7th March 2007, 06:10
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.
<br>

mister_e
- 7th March 2007, 06:14
:eek: yeah, weird... maybe a beta V2.46? who knows :D
12:14 here so http://www.mister-e.org/Pics/GoodNight.gif

Darrel Taylor
- 7th March 2007, 06:34
Beta 2.46 http://darreltaylor.com/files/ROFL.gif
<br>

skimask
- 7th March 2007, 06:44
Beta 2.46 http://darreltaylor.com/files/ROFL.gif
<br>

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

Darrel Taylor
- 7th March 2007, 06:52
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.
<br>

b1arrk5
- 7th March 2007, 15:29
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.

mister_e
- 7th March 2007, 22:17
P.P.S. The patch is a PITA.

mmm PITA
http://www.thefreshloaf.com/up/20050410pitas.jpg
;)

b1arrk5
- 16th March 2007, 01:49
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!

Darrel Taylor
- 16th March 2007, 09:28
Isn't that what Steve and I said in Post #24 and 23?
<br>

b1arrk5
- 16th March 2007, 18:21
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.

Darrel Taylor
- 16th March 2007, 23:35
Oh, woops. Now I get it. :o

Woohoo.
<br>

Andre_Pretorius
- 18th January 2009, 18:35
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


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


'*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

Darrel Taylor
- 18th January 2009, 20:47
And my setup i am running a 48M cristal

Ummm, you mean you are running a 20mhz crystal, with DEFINE OSC 48?

I Hope.
<br>

Andre_Pretorius
- 19th January 2009, 04:21
No, 48M cristal with define osc 48

Darrel Taylor
- 19th January 2009, 04:59
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.
<br>

b1arrk5
- 20th January 2009, 00:56
Also, SPBRG 77 is the value if SPBRGH = 0, since you have SPBRGH set to 1, then SPBRG should be 56.

Jerry