Error programming 10F222


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    brooklyn
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    holy crow.
    i was planning on setting up a breadboard to do ICSP on the thing... i'll still give that a go, while i'm waiting for my shipment from meLabs!
    i have used the 12F parts [8 pin] with the standard ZIF with great success, and just assumed... yeah, right.
    it is still possible to be smarter than yesterday.

    thankyou kind Charles for waking me from my stupor.

  2. #2
    Join Date
    Aug 2006
    Location
    brooklyn
    Posts
    33


    Did you find this post helpful? Yes | No

    Default Working with reservations

    Hi,
    Got that 10F ZIF adapter. I had also thrown together an ICSP setup on my breadboard. Both work! Iʻd rather use the ZIF, and free up the breadboard!

    SO, after getting a good test running, I put together my first draft program and got ʻUnable to fit Variableʻ error. Nice. Turns out that PBP uses 22 bytes of RAM for storing data that it uses to run my code. Well, the 10F222 has 23 bytes of RAM... I got 1 byte variable to use in my PBP program! This is a rude awakening.
    The essence of my project is to fade 3 LEDs. Not much heavy lifting going on here. I started incorporating the TMR0 in my software PWM loop. That worked barely. The basic structure of my PWM loop is:

    FOR X = 0 TO 100
    FOR Y = 0 TO 100
    IF Y < X THEN
    GPIO = 1
    ELSE
    GPIO = 0
    ENDIF
    NEXT Y
    NEXT X

    to fade the other way, you just mirror the above loop.
    You see that Iʻm using 2 byte variables here...
    So what Iʻve done is to commandeer the OSCCAL register. There is an issue with bit 0 of OSCCAL and that it effects GP2. I just increment OSCCAL by 2 when Iʻm using it. I got some usable LED fading happening and found a free variable!
    Iʻm still not happy though. I really need one more byte var to get the effect that I want. Anybody have any ideas? Is it possible to tap into the RAM area that PBP uses? Maybe thereʻs a DEFINE somewhere that I can make do my bidding...?

    Iʻll post the code soon. Itʻs on another machine
    Joel

  3. #3
    Join Date
    Aug 2006
    Location
    brooklyn
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    Here's the code that I'm working with.
    Code:
    @ Device PIC10F222, IOFSCS_8MHZ, MCPU_OFF, WDT_OFF, PROTECT_OFF, MCLR_OFF
    
    
    OPTION_REG = %11010010 'GPWU_OFF, GPPU_OFF, TOCS_OFF, TOSC_HIGH>LOW, PSA_TMR0, PS_1:8
    
    ADCON0 = 0
    TRISIO = 0
    GPIO = 0
    
    Time var byte
    
    pause 100
    
    Main:
        OSCCAL = 2
        GOSUB FADE1A
        PAUSE 1000
        OSCCAL = 2
        GOSUB FADE2A
        PAUSE 1000
        OSCCAL = 2
        GOSUB FADE3A
        PAUSE 100
        
    GOTO MAIN
    
    
    
    
    Fade1A:
        FOR TIME = 0 TO 250
        IF TIME < OSCCAL THEN
            IF TIME < 80 THEN
                GPIO = 7
            ELSE
                GPIO = 6
            ENDIF
        ELSE
            GPIO = 7
        ENDIF
        NEXT TIME
        OSCCAL = OSCCAL + 2
        IF OSCCAL = 250 THEN
            OSCCAL = 2
            GOSUB FADE1B
            RETURN
        ENDIF
        GOTO FADE1A
    Fade1B:
        FOR TIME = 0 TO 250
        IF TIME < OSCCAL THEN
            GPIO = 7
        ELSE
            IF TIME > 170 THEN
                GPIO = 7
            ELSE
                GPIO = 6
            ENDIF
        ENDIF
        NEXT TIME
        OSCCAL = OSCCAL + 2
        IF OSCCAL = 250 THEN        
            RETURN
        ENDIF
        GOTO FADE1B
     
    'the other two subroutine blocks are the same as above 
    'with GPIO = 5 and GPIO = 3

    It looks like it might be possible to use POKE and PEEK to access the RAM area that is restricted... I'm going to play around abit, I could get away with 1 more byte var, but I would love to have 2 more!

  4. #4
    Join Date
    Aug 2006
    Location
    brooklyn
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    Well, I think I got what I need.
    I have been tweaking the options and have found that if I use MPASM I can get two more byte variables! So total including commandeering the OSCCAL register is 4 byte variables. I'm on my way.
    Would love to know if anyone has any further ideas about how to squeeze more RAM out of PBP

Similar Threads

  1. 10F222 ADC Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 30th October 2008, 03:46
  2. 10f222
    By Meriachee in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 31st October 2006, 17:09

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