PDA

View Full Version : 18F4550 XTAL Problem



Pesticida
- 22nd January 2008, 18:52
Hi,

I have a little Problem ,I have one 18F4550 Chip that running with a 20 Mhz Xtal.

My Problem is that I can not find the Right setting to run my Software on that Chip.
I need just a Normal RS232 Communication and not USB but I think that my settings are wrong!

I have this:

Define OSC 20
OSCCON = %01111100
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 64 ' 19200 Bauds
DEFINE HSER_CLROERR 1
UCON = %00000000
RCSTA.7 = 1
TRISC.7 = 1
TRISC.6 = 1

.......
Hserout ..........
.......
End

I have use SPRBG Calculator for the Baudrate (20 Mhz and 19200)

But dont work I receive on my PC just wrong Data.

Maybe some one can Help me to find the right Setting,I have experience with 18F452 and other PICs but with 18F4550 I dont understand what I make wrong .

Thanks for any answer !

Regards Pesti

skimask
- 22nd January 2008, 19:41
Hi,
I have a little Problem ,I have one 18F4550 Chip that running with a 20 Mhz Xtal.
My Problem is that I can not find the Right setting to run my Software on that Chip.
I need just a Normal RS232 Communication and not USB but I think that my settings are wrong!
......
But dont work I receive on my PC just wrong Data.
Maybe some one can Help me to find the right Setting,I have experience with 18F452 and other PICs but with 18F4550 I dont understand what I make wrong .
Thanks for any answer !
Regards Pesti

Do you have a MAX232 (or equivalent) in the circuit somewhere?

Pesticida
- 22nd January 2008, 19:45
Oh yes with max232 and other PIC 18F452 is working but with 18F4550 dont work I think that this is a Xtal setting Problem.

Regard Pesti

skimask
- 22nd January 2008, 19:46
Oh yes with max232 and other PIC 18F452 is working but with 18F4550 dont work I think that this is a Xtal setting Problem.

Regard Pesti

Did you set HS instead of XT in the config's?

Pesticida
- 22nd January 2008, 19:52
Ok I think that I found the Problem,I have 20 Mhz Xtal but I must write Define OSC 48 while 20/5 = 4*24= 96 Mhz for PLL / Divider 2 = 48 Mhz CPU Clock.


Thank You Skimask!

Regards Pesti

skimask
- 22nd January 2008, 19:55
Ok I think that I found the Problem,I have 20 Mhz Xtal but I must write Define OSC 48 while 20/5 = 4*24= 96 Mhz for PLL / Divider 2 = 48 Mhz CPU Clock.

Regards Pesti

Ahhh...that makes sense.
I thought you had a 20Mhz crystal and 20Mhz CPU clock.
But, if that's the case, then your dividers (SPBRG) are going to be off also. Off the top of my head, I think 153 or 154 will do for SPBRG at 48Mhz CPU clock.
I could be wrong...

Pesticida
- 22nd January 2008, 20:12
Yes You are Right I have for SPBRG 155.:-)

Thanks

Regards Pesti