PIC10F202 Variable trouble


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171

    Default PIC10F202 Variable trouble

    I'm converting an old PIC12C671 program to run on a a 10F202 but for some reason it's not working.

    I'm using microcode 2.3 and pbp2.46 it has the 10f202 library in it.

    The errors I get are: ERROR unable to fit variable dim
    it also says this about every other variable I'm using

    Any thoughts would be greatly appreciated

    Program starts like:

    @ device pic10F202, mclr_off, protect_off, wdt_off

    TRISIO = %1100

    triac VAR GPIO.2
    trigger VAR GPIO.3

    dim VAR WORD
    Time VAR WORD
    Time2 VAR BYTE
    startup VAR BYTE
    b0 VAR BYTE

    Clear
    GPIO = 0
    dim = 100


    Start:

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    The 10F202 has only 24 bytes of SRAM (Data Memory). The System variables associated with PBP require 20 bytes - that leaves you with 4. (From the PBP manual "Several system variables, using about 24 bytes of RAM" - its only 20 for the 10F202)

    You can have 2 additional WORDS or 4 additional BYTES- that is it (you have 7 bytes defined). Can you reuse variables?

    EDIT - The PBP manual is great - read section 7.6. If you do not have nested Gosubs or they are not nested 4 deep you might be able to steal a byte or two from the stack array.
    Last edited by paul borgmeier; - 6th October 2006 at 04:26.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Like the last edit on yr reply - tho not sure how to do it, the program is only 183 words long and I have no gosubs at all and only one goto at the very end.

    Are you able to elaborate on how to steal a couple of bytes from the stack?

    I was thinking that the 10F202 was going to be a neat little chip to use, but am having 2nd thoughts about it now knowing the ram limitations. Would be good to see if PBP could use only simple instructions for the 10F20X series chips and use say only 12bytes.

    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Hi George,

    If it is not a secret government project, can you post your code?


    -------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Sure, all it does is dims a light down after 20 minutes of being on.

    @ device pic10F202, mclr_off, protect_off, wdt_off

    TRISIO = %1100

    triac VAR GPIO.2
    trigger VAR GPIO.3

    dim VAR WORD
    Time VAR WORD
    Time2 VAR BYTE
    b0 VAR BYTE

    Clear
    GPIO = 0
    dim = 100


    Start:

    time = time + 1 'increment timer in 1/50 seconds

    IF time > 30000 Then 'make a 10 min increment
    time = 0
    time2 = time2 + 1
    EndIF

    b0 = b0 + 1 'increment for every 4 phase cycles
    IF b0 >= 3 Then b0 = 0

    IF time2 >= 2 AND b0 = 2 Then dim = dim + 1 'if over 20 min then start dimming dim period 4 cycles = 10 mins

    IF dim > 7500 Then dim = 7500 'down to dim level - 9000 = off, 7500 approx 15%

    if time2 > 72 then 'turn off after 12 hours
    dim = 9000
    time2 = 73 'prevent from cycling
    endif

    LowSide: 'look for trigger points and trigger triac

    IF trigger = 1 Then lowside 'wait for phase to go low
    GPIO.5 = 0 'weight input to sense zero crossing
    PauseUs dim 'wait for dim period
    Output triac 'fire triac
    triac = 0
    PauseUs 400
    Input triac

    HighSide:

    IF trigger = 0 Then HighSide
    GPIO.5 = 1
    PauseUs dim
    Output triac
    triac = 0
    PauseUs 400
    Input triac

    GoTo start

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


    Did you find this post helpful? Yes | No

    Default

    It's the down side of those nifty 10Fs with most compiler. The use of assembler is handy in this case... but i'll have a look at this one to see what i can do...
    Last edited by mister_e; - 9th October 2006 at 03:58.
    Steve

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

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. problem with variable on PIC10f202
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th October 2009, 17:29
  3. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Trouble with Serin2 and variable size
    By Ryan7777 in forum Serial
    Replies: 6
    Last Post: - 5th October 2006, 16:40

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