Pulsout Pic16F630 @16Mhz problem


Closed Thread
Results 1 to 19 of 19
  1. #1
    Join Date
    Feb 2022
    Posts
    51

    Default Pulsout Pic16F630 @16Mhz problem

    Hi everyone,

    I'm trying to understand a problem with a Pic16F630 equipped with a 16Mhz resonator (3 legs).
    The very simple verification code is below.
    The pulses delivered are 240msec for a command "PULSOUT PORTC.3, 100"!?
    And the pulse result is the same if I delete the "DEFINE OSC 16" line !!?
    (But the 200 pause is then reduced to 50 msec !)

    I kept the factory OSCCAL value which IC-Prog copies to the right address.

    I did not have this problem with a Pic16F84A...
    What is my mistake or oversight?

    Thank you in advance.

    -----------------------------------------------------------
    '**** CODE: *****
    ' TESTPIC16F630.PBP
    ' TEST PIC16F630 Pulsout Command

    ' Pic Specifications
    @ Device Pic16F630,HS_osc, wdt_off, pwrt_on,protect_off, mclr_off
    DEFINE OSC 16

    ' i/o Definition
    'All OUTPUT
    TRISA =0
    TRISC =0
    ' All pins at Logic Low
    PORTA = 0
    PORTC = 0

    Loop:
    pulsout PORTC.3, 100
    pause 200
    Goto LOOP

  2. #2
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    Without pulling out a data sheet to check, most PICs have some sort of OSCCON Register where you have to tell it to use the external crystal, oscillator, RC, or use the internal oscillator. I'm betting that by not using the OSCCON Register, it is defaulting to 4 MHz Internal Oscillator. By DEFINEing OSC 16, PBP is counting clock ticks as though you were at 16 MHz using your external resonator, where in reality, you're using the internal 4 MHz clock.

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    The pulses delivered are 240msec for a command "PULSOUT PORTC.3, 100"!?
    by 240mS do you mean 240 micro seconds. a more likely result


    What is my mistake or oversight?
    not reading the manual

    5.59 PULSOUT
    PULSOUT Pin, Period
    Generates a pulse on Pin of specified Period. The pulse is generated by toggling the pin twice, thus the initial state of the pin determines the polarity of the pulse. Pin is automatically made an output. Pin may be a constant, 0 - 15, or a variable that contains a number 0 - 15 (e.g. B0) or a pin name (e.g. PORTA.0).
    The resolution of PULSOUT is dependent upon the oscillator frequency. If a 4MHz oscillator is used, the Period of the generated pulse will be in 10us increments. If a 20MHz oscillator is used, Period will have a 2us resolution. Defining an OSC value has no effect on PULSOUT. The resolution always changes with the actual oscillator speed.
    ' Send a pulse 1mSec long (at 4MHz) to Pin5
    PULSOUT PORTB.5,100
    PULSOUT is a legacy command that is included for compatibility with other languages.
    Warning I'm not a teacher

  4. #4
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    @ Mpgmike,
    Now you're confusing me
    (I already don't know English very well, thanks to the automatic translators).
    Well, actually I was an amateur user of the BS2x BasicStamp and I try to pour some programs into one or the other PIC.
    The registers of the PICs and the commands other than the pure Basic of the Stamp, I don't know too much!
    So, isn't declaring the High Speed fuse then sufficient for PicBAsicPro Compiler, as I wrote in my program?
    So I don't understand your sentence "as if you were at 16 MHz using your external resonator, when in reality you are using the internal 4 MHz clock."
    --> So does it work in 4Mhz or 16Mhz?

    @Richard
    (Yes, 240µsec!)
    You say that setting OSC has no effect on PULSOUT but that the resolution depends on the crystal used.
    What is the point of defining OSC?
    And considering what Mpgmike said above, at what frequency does my Pic equipped with a 16Mhz resonator and high speed fuse indication work?

    Here are the pulses I read on a logic analyser:

    WITHOUT indicating Define OSC 16 :
    PAUSE 200 = 50 msec (Isn't the resolution at 4Mhz 10µsec??)
    PULSOUT 100 = 240µsec

    Isn't the resolution at 4Mhz 10µsec?

    WITH Define OSC 16 :
    PAUSE 200 =200 msec
    PULSOUT 100 = 240 µsec also

    (Theoretical resolution at 16Mhz should be 2.5 µsec I think).
    So the PIC would work well here at 16Mhz!

    I have to admit that I'm getting confused here with the Pause and Pulsout resolutions and I'm trying to understand

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    So, isn't declaring the High Speed fuse then sufficient for PicBAsicPro Compiler, as I wrote in my program?
    for this chip yes
    You say that setting OSC has no effect on PULSOUT but that the resolution depends on the crystal used.
    ?
    its a legacy [old ] command, it does not use the OSC define in its operation


    What is the point of defining OSC
    non legacy commands do use the OSC define in their operations

    And considering what Mpgmike said above
    is incorrect and out of context for that chip



    (Theoretical resolution at 16Mhz should be 2.5 µsec I think).
    So the PIC would work well here at 16Mhz
    thats it
    Warning I'm not a teacher

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    looks like the forum is broken. cannot edit last post

    I have to admit that I'm getting confused here with the Pause and Pulsout resolutions and I'm trying to understand
    pause uses OSC define to calculate TIME , Pulsout does not
    Warning I'm not a teacher

  7. #7
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    I was wondering about the resolutions of the PAUSE command:

    With "DEFINE OSC 16", PAUSE 200 gives a delay of 50 msec
    The resolution here is therefore 250µsec per "unit".

    WITHOUT "DEFINE OSC 16", PAUSE 200 gives a delay of 200 msec
    The resolution here is 1msec per "unit".

    Right?

    --> What are legacy commands, I don't know this term

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    i'm not sure what ver of pbp you are using but

    @ Device Pic16F630,HS_osc, wdt_off, pwrt_on,protect_off, mclr_off

    is old stuff, and probably case sensitive
    HS_osc looks doubtful
    if this line is incorrect then the actual config fuse you are setting is the pbp default not what you think.
    the default will be most likely use a 4mhz clock

    With "DEFINE OSC 16", PAUSE 200 gives a delay of 50 msec
    means the osc is 4mhz not 16, so your config line is incorrect

    The resolution here is therefore 250µsec per "unit".
    pause is always in mS but the actual osc must march the defined OSC

    What are legacy commands, I don't know this term
    commands that resemble old basicstamp style commands ,they are not as well integrated in the pbp operating environment
    Warning I'm not a teacher

  9. #9
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    Strange, I have a program using pulsin and pulsout that runs perfectly on Pic16F84A/16Mhz and I try to put it on a Pic16F630./16Mhz .. but nothing works ;(
    I was using 16Mhz for better accuracy.
    I spent the day there, without success.
    My neurons are melted.

  10. #10
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    I am using a 20 year old compiler PBP 2.40/2.46.
    But I can confirm that when IC-Prog loads the Hex file, the fuse is set to HS.
    And the same program ran perfectly on a Pic16F84A

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    if you have pbp3 then a config looks loke this
    Code:
    #CONFIG
      __config  _HS_OSC & _WDT_ON & _PWRTE_OFF & _MCLRE_ON & _BODEN & _CP_OFF & _CPD_OFF
    #ENDCONFIG

    @ Device Pic16F630,HS_osc, wdt_off, pwrt_on,protect_off, mclr_off

    looks wrong for any version
    Warning I'm not a teacher

  12. #12
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    I just tried this command.
    It is not recognised on my PBP 2.40
    But I guess without this configuration line, setting the fuses in IC-Prog is also valid and sufficient?
    "My" command was valid for my Pic16F84A.

  13. #13
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    Quote Originally Posted by zorgloub View Post
    I am using a 20 year old compiler PBP 2.40/2.46.
    But I can confirm that when IC-Prog loads the Hex file, the fuse is set to HS.
    And the same program ran perfectly on a Pic16F84A
    the chip is running @4mHz so something is not right


    you might need to find noah or someone else out of the ark
    Warning I'm not a teacher

  14. #14
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    How can you tell it's running at 4Mhz?

  15. #15
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    from this post


    With "DEFINE OSC 16", PAUSE 200 gives a delay of 50 msec
    The resolution here is therefore 250µsec per "unit".


    WITHOUT "DEFINE OSC 16", PAUSE 200 gives a delay of 200 msec
    The resolution here is 1msec per "unit".
    Warning I'm not a teacher

  16. #16
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    Well, I'll leave it for today.
    Thank you for your support.
    Have a good evening and a good night.

  17. #17
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    Hi Richard,
    (The resolution at 16Mhz is theoretically 2.5µsec.)
    So if PULSOUT 100 gives me a pulse of 0.24 msec, the resolution here is 2.4µsec, which would indicate that the Peak is running at 16Mhz.
    No ?

  18. #18
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    So if PULSOUT 100 gives me a pulse of 0.24 msec, the resolution here is 2.4µsec, which would indicate that the Peak is running at 16Mhz.
    sounds right.

    however
    if osc = 16mhz and define OSC 16 is set then pause 200 will pause 200mS
    if not then something is wrong , PULSOUT would not be my way to test osc speed.


    also code snippets are not meaningful in this situation at least until the chip is confirmed configured as intended

    do post entire code including config word in code tags to make it easy for anyone one interested in assisting
    Warning I'm not a teacher

  19. #19
    Join Date
    Feb 2022
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Pulsout Pic16F630 @16Mhz problem

    Hello Richard
    Well, I solved the problem of the operation of my program on the Pic16F630.
    Regardless of the strange problem of the duration of the pauses, I have no problem with the management of Pulsin / Pulsout under 16Mhz.
    In fact, I had no Pulsout signal on some outputs because I had not disabled the comparator of this Pic (CMCON = 7).
    The duration of the pauses does not impact the progress of my program.
    Thanks for your general help.

    Translated with www.DeepL.com/Translator (free version)

Similar Threads

  1. PAUSEUS Using a 16MHz Oscillator
    By rsocor01 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th October 2013, 22:17
  2. weird pulsout problem
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th January 2012, 19:39
  3. LCD works at 4MHz, but not 12 or 16MHz
    By Max Power in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th June 2008, 01:23
  4. Encoder Ht6p20b Using Pic16f630 Decoder
    By Lucas de Paula in forum General
    Replies: 1
    Last Post: - 18th April 2007, 05:36
  5. Can anyone help at getting OWIn & OWOut to work @ 16MHz?
    By jessey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th January 2006, 11:08

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