18f2550 USB OSC Problem


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2008
    Posts
    14

    Unhappy 18f2550 USB OSC Problem

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

  2. #2
    Join Date
    Feb 2003
    Location
    Sydney, Australia
    Posts
    126

    Default

    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.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Yup, post your C18 pragma line and we will be able to help. seems to me that the CPUDIV is wrong... well i think...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Oct 2008
    Posts
    14

    Default

    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
    Last edited by serkanc; - 28th October 2008 at 21:34.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    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...
    Last edited by mister_e; - 28th October 2008 at 21:45.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Oct 2008
    Posts
    14

    Default

    I wil check again everything i done.. Possibble i made a mistakeee

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    reduce your code to a blink test and post everything here using the code tags...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Oct 2008
    Posts
    14

    Default

    Thanks for your interest.

    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

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    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/show...&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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Oct 2008
    Posts
    14

    Default

    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 ?
    Last edited by serkanc; - 29th October 2008 at 19:45.

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. USB CDC Communications for Dummies!
    By Squibcakes in forum USB
    Replies: 104
    Last Post: - 15th January 2014, 13:43
  2. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  3. 18F2550 MCRL/RE3 problem with USB bootloader Microchip
    By Ronald123 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th September 2007, 10:48
  4. Speed of USB EasyHID and Time problem
    By sjohansson in forum USB
    Replies: 10
    Last Post: - 18th January 2007, 22:21
  5. 18f2550 'access is denied' USB error?
    By Giulio in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 30th December 2006, 14:29

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