PDA

View Full Version : 18f2550 USB OSC Problem



serkanc
- 28th October 2008, 12:17
I have programmed my 18f2550 bootload.hex which I have compiled with c18. I can send hex files with PDFSUSB. I'm using microcode studio.. I have no problems with any code except OSC settings... I have defined OSC as 48 MHZ at the beginning of program, but it's faster than that.. I put pause 1000, but it pauses 0.25 second...
I tried to change config settings for the bootloader hex, but so i have got problems with PDFSUSB... So i think there is a solution with OSC setting..
I need someone to help me...

bcd
- 28th October 2008, 21:57
How bizarre - I was loading the same code into a 18f2550 only yesterday !
Did you change the CONFIG registers in your code as these control the actual OSC speed.

You need to have OSC48 in the code as this is the internal rate the PIC runs at - you set the PLL frequency based on your crystal speed.

Let me fire up the laptop and get the CONFIGs I used for 4MHz and 20MHz which I know work with my breadboard circuit.

bill.

mister_e
- 28th October 2008, 22:12
Yup, post your C18 pragma line and we will be able to help. seems to me that the CPUDIV is wrong... well i think...

serkanc
- 28th October 2008, 22:30
Thanks for help.. But I only use c18 for bootload hex. I'm using PBP with microcode studio for my software...
I didn't change lines.. PDFSUSB works fine.. I'm using 20 MHZ Crystal with 15pf capacitor...
I wrote DEFINE OSC 48 but it's faster.. It causes also problems on serial comm with another PICs...
I think config bits are normal...
#pragma config PLLDIV = 5 // (20 MHz input)
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 2 // Clock source from 96MHz PLL/2
#pragma config FOSC = HSPLL_HS

mister_e
- 28th October 2008, 22:41
Your program speed will relly on the config fuse setting of your bootloader, if they are false, your program won't work as expected... that's for sure. You can still alter the config fuse at run time.

They seems to be great.. at least to me... hummm...

serkanc
- 28th October 2008, 22:57
I wil check again everything i done.. Possibble i made a mistakeee

mister_e
- 28th October 2008, 23:25
reduce your code to a blink test and post everything here using the code tags...

serkanc
- 29th October 2008, 10:19
Thanks for your interest.
http://www.youtube.com/watch?v=F1QApgYX9BI
This is what I have done.. So I want to make serial connection

Now i reduced my code.. Now it's working... but if I use PAUSE 1000 without for.. next, it interrupts USB connection.. But leds blinking right time... I will try now serial connection again..

Another question : For what do I need DEFINE RESET_ORG 800h and DEFINE INTERRUPT_ORG 808h ?

define OSC 48
DEFINE LOADER_USED 1
DEFINE RESET_ORG 800h
DEFINE INTERRUPT_ORG 808h
I VAR word
LOW PORTB.0
HIGH PORTB.1
USBINIT

dongu:
FOR I=1 TO 1000
usbservice
pause 1
NEXT I
toggle portb.0
toggle portb.1
goto dongu

mister_e
- 29th October 2008, 18:21
Yup, USBService work a treat when you take care of it each millisecondes or so. Another route is to use a Timer intterrupt such as in the first USBDemo version.

EVEN BETTER, look at the following modified version A.K.A post #148 which use Darrel's instant interrupts...
http://www.picbasic.co.uk/forum/showpost.php?p=30682&postcount=148

so now you no longer need to care about USBSERVICE, it will be done automatically... BUT i've NEVER tried with the bootloader firmware installed :eek:

serkanc
- 29th October 2008, 20:36
Can you tell me or give me the code, how can I add TMR0 interrupt to my project ?
But I understood after your explenation what this lines mean :)
DEFINE RESET_ORG 800h
DEFINE INTERRUPT_ORG 808h
I think Interrupts begins after 808h so when an interrupt occurs it will not jump to bootloaders section .. Can be ?

mister_e
- 29th October 2008, 21:52
have a look at USBDemo, first post, first code, everything should be clear after that.
http://www.picbasic.co.uk/forum/showthread.php?t=5418