Problem with 16F737


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2007
    Posts
    11

    Default Problem with 16F737

    I'm having problems with my first PIC project. I'm using a PIC 16F737 to make a 16 channel fireworks sequencer. The breadboard prototype works great. The only issue I have is that "Pause 1" is giving me approx 134mS of delay, not 1 mS. Pause 100 gives me 13.4 seconds, not 100mS & that is maximum. Pause 1000 also gives me 13.4 seconds delay. I'm using the internal oscillator. Could this be the source of my problems?
    Attached Files Attached Files

  2. #2


    Did you find this post helpful? Yes | No

    Smile See your manual

    Hi,

    Take a look at the PicBasic Manual. It's well explained and a free download.

    If you use a 4 MHz crystal, Pause is in milliseconds so...

    Pause 1000 will pause 1 second

    You can pause up to 65 535 milliseconds (16 bits)

    Your problem could be your clock or you oscillator calibration value. Last address in the program memory.

  3. #3
    Join Date
    Aug 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    It may be too well explained, because it's absolutely Greek to me. Most of the manual and all of the datasheet are over my head.
    Frankly, I don't even know what you mean by "last address in the program memory".
    I've got the datasheet & can't really see anything beyond some vague references here & there to OSCCON & OSCTUNE, but nothing about how to use them. The PBP manual say to "see the speed section", which I can't find.
    Last edited by rangerdoc; - 29th October 2007 at 02:34.

  4. #4


    Did you find this post helpful? Yes | No

    Smile More

    I'll try to explain more. Anyoone can feel free to add.

    Your PIc has 2 types of memory. Program and data memory. Your program is compiled and loaded int o program memory. Your data is stored in data memory which is volatile memory meaning when you power off your PIC, it is erased.

    Your memory is divided into addresses. The last address in your program memory has a value put in by Microchip. This value calibrates your PIC as close as possible to the clock specified in the datasheet. If you erase your chip, you lose your calibration value. So the first thing you should do when you put a PIC in your programmer is read it and write this value down on paper in case you overwrite it by accident. This value is unique to each PIC.

    What i'm not so sure of is, will this value make your PIC go to 4.00000000 MHz or will it be off a little. Maybe someone else can answer that????? Is this value good enough for serial communication?

  5. #5
    Join Date
    Aug 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    I get the feeling we're talking about two different things here:
    I'm not looking to trim or calibrate the internal oscillator for communications or anything precise. The PIC 16F737 has several internal oscillator frequencies. Mine appears to be running at the 35kHz instead of 4MHz. I have no idea of how to change it.
    Let me clarify the project. I'm building quite a few of these sequencers... Dozens. I want to use the internal oscillator to keep parts & cost to a minimum.
    These are really simple. One digital input, 16 outputs... nothing more. no communications. I have my existing firing panels which will trigger the input high via an optocoupler. The outputs with then go high at the intervals defined by the delay variable. That's it.
    I really have no need to go any deeper with PicBasic or with PICs than this as these boards are my end goal. Once they are working, I'm done. I just need the outputs to sequence faster than they are now.
    Hope this helps.

  6. #6
    Join Date
    Aug 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Got it. Searching the forum did it once I knew what to look for:

    http://www.picbasic.co.uk/forum/showthread.php?t=813

    I entered the line "OSCCON = $60" & that got the clock running at 4MHz.

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You need to write to the OSCCON register to select 4MHz. The default value of OSCCON at
    power-up is all 0's. That sets the internal osc at 31.5kHz by default.

    OSCCON = %xxxxxxxx (replace x's with value shown in data sheet for selecting 4MHz)

    Edit: Nice work. It's not that hard is it...;o}

    Not bad for your first PIC project.
    Last edited by Bruce; - 29th October 2007 at 03:56. Reason: You're fast.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8


    Did you find this post helpful? Yes | No

    Default Voila

    I think Bruce nailed it. Good answer Bruce.

    I have 2 questions concerning that. 1st one I already asked.

    1. Are the internal oscillators precise enough to do serial communication?

    2. Do all chips have OSCCON? I search the 16F676 PDF... nothing

    hmm??????????

  9. #9
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    1. Are the internal oscillators precise enough to do serial communication?
    Yep. Newer parts with 1% internal oscillators are.

    As long as the PIC will operate in a moderate environment like indoors. If you plan to use
    it outdoors in extreme heat or cold, go with an external crystal. The internal osc will drift
    when exposed to extreme temperatures.

    2. Do all chips have OSCCON? I search the 16F676 PDF... nothing
    No not all of them have an OSCCON register. Most of them with an internal oscillator that
    offers various speeds do. So you can select or change internal osc speeds.

    The 16F676 doesn't have an OSCCON register. Its internal osc is fixed at 4MHz. It does
    however have a factory calibration value tucked away in the last program memory space.
    You tell PBP to fetch & load this into the OSCCAL register with the DEFINE OSCCAL_1K 1
    option.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  10. #10


    Did you find this post helpful? Yes | No

    Smile You da man Bruce

    Many Thanx to you.

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 19:52
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. Microcode Studio 18f2455 problem?????
    By volkan in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 21st May 2007, 21:04
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59
  5. weird 12F629/675 problem
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th October 2004, 01:08

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