18F2620 OSC Confusion


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2005
    Posts
    10

    Question 18F2620 OSC Confusion

    Hi All,
    I'm Very new here, Got my PBP 2.46 software with MCSP and Serial programmer by Melabs and have been writing some code in basic for the first time. Alot easier than Ansi C, thats for sure. Anyway, I'm really glad to be here.
    Now on to my problem, I'm communicating to my 18f2620 with great success except for the fact that the speed at which I'm communicating is 2400 Baud. My intention is to be at 9600. The other unusal fact is that I have two blinking lights that Blink at a rate 4 times slower than the 500ms I have selected. So both Baud and Flashing lights are 1/4 what the should be. So i'm sure their must be an include file that i should be using but I didnt find exactly what I was looking for In the Forum. I was hoping for some guidence.

    I should mention that each time i use the serial programmer it selects XT for my OSC at the top of "Configuration Screen"- (sorry dont really know the name of that screen.) If I select INTRC or INTRC Clockout it will simply change my selection before i program it.

    My thought is that I need to define it or add an include file. But How.

    I'm not using an RS232 chip, I'm talking Directly as it has an internal USART. so I think I should be using INV output, and I wanted to eliminate all possibilities for human error until I get some stick time with my new toys...

    Any Ideas?

    Ash Man

    'Code:

    loop:
    SEROUT2 portc.6, 16468, ["Hello World!", 13,10] ' 9600, I think

    High PORTB.0 ' Turn on LED connected to PORTB.0
    Pause 500 ' Delay for .5 seconds

    Low PORTB.0 ' Turn off LED connected to PORTB.0
    Pause 500 ' Delay for .5 seconds

    High PORTB.3 ' Turn on LED connected to PORTB.0
    Pause 500 ' Delay for .5 seconds

    Low PORTB.3 ' Turn off LED connected to PORTB.0
    Pause 500 ' Delay for .5 seconds
    Goto loop ' Go back to loop and blink LED forever

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


    Did you find this post helpful? Yes | No

    Default

    wich crystal speed you have???

    let's say 20MHZ.... So set config fuse to HS OSC at programming time and add
    DEFINE OSC 20
    at the top of your code

    XT is for 4MHZ crystal only.

    If you select INTROSC, on F2620 the default setting is...1 MHZ wich explain the 1/4 time speed you have. Default PBP xtal speed is 4MHZ.
    to set internal Oscillator speed, write directly to OSCCON register.
    OSCCON=%01100000 '=> set internal osc to 4MHZ
    the above will fix your problem.

    Be friend with this

    Welcome to the forum and have fun!!!
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    ooh i forget, you can't configure the internal USART to talk directly to the PC... you need MAX232 or else inverter. BUT you can use software command like SEROUT, SEROUT2 and use the inverted mode. Just use a resistor in serie will work.
    Steve

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

  4. #4
    Join Date
    Jun 2005
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Yippi Ki A

    Thanks, Worked Like a Dream!
    Ash

Similar Threads

  1. Internal vs. external osc for comms
    By mtripoli in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th January 2010, 14:58
  2. Define osc 1
    By ronsimpson in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st October 2009, 06:35
  3. 18f2550 USB OSC Problem
    By serkanc in forum USB
    Replies: 10
    Last Post: - 29th October 2008, 20:52
  4. 18F458 and 20MHz osc problem...
    By batee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th October 2004, 20:16
  5. 12f675 internal osc question.....
    By Gabe@SPdFtsh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th January 2004, 06:33

Members who have read this thread : 0

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