News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

12C508A Program does not run on 12F508

Started by thetrueman, Jul 27, 2024, 09:28 PM

Previous topic - Next topic

thetrueman

Hi,
In old Lovely Proton Basic, I made a simple test program to turn on/off some outputs and program runs ok in 12C508A.

Same program does not run on 12F508 when we select on top of .BAS file and compile/download. It simulates OK in Proteus but not in Real PIC12F508.

What I find by various tries... outputs switch ON but when I switch OFF any one output, the program RESETS from start. Is not it strange??? Thanks.

RGV250

Hi,
Without posting the code I doubt you will get any replies as this is like asking where is the needle in the haystack.

Bob

RGV250

Hi,
Another thought, have you had a look through the datasheet for any differences in the config settings between the 2 devices.

Bob

thetrueman

#3
Here is code... I tried many options but failed. Datasheets almost same except some upgradation in F508. Whenever only Out3 is Low (or even any output), it resets which I understood by changing time in Initialize sub.

    Device = 12F508
'    Device = 12C508A
    XTAL = 4
    Config INTRC_OSC, CP_ON, WDT_OFF, MCLRE_ON
    OPTION_REG.5 = 0    'Now GPIO.2 (T0CKI) can be used for I/O.
    OSCCAL = %00000000      'Center Frequency Calibration
   
    TRISIO = %001100 
'    TRISB = %001100
'    TRISC = %111111
    GPIO = 0 ': PORTB = 0 

    Symbol IN1  = GPIO.2     
    Symbol Out1 = GPIO.4
    Symbol Out2 = GPIO.5     
    Symbol Out3 = GPIO.0     
    Symbol Out4 = GPIO.1 
                         
'    Symbol IN1  = PORTB.2     
'    Symbol Out1 = PORTB.4
'    Symbol Out2 = PORTB.5     
'    Symbol Out3 = PORTB.0     
'    Symbol Out4 = PORTB.1     
   
    Dim Time As Byte        'Time Count Variable
   
    GoTo Initialise
       
Initialise:   

'    Clear
    DelayMS 1000
    GoTo Start
   
Start: 
        Out1 = 1 ': Out4 = 0
        DelayMS 1000
        Out2 = 1 ': Out1 = 0
        DelayMS 1000
        Out3 = 1 ': Out2 = 0
        DelayMS 1000
        Out4 = 1 : Out3 = 0
        DelayMS 1000
   
    DelayMS 1
    GoTo Start
       
End

RGV250

Hi,
I have never used : like that and cannot find it in the manual.
Have you tried this which is how I would do it.
Start:
        Out1 = 1
        Out4 = 0
        DelayMS 1000
        Out2 = 1
        Out1 = 0
        DelayMS 1000
        Out3 = 1
        Out2 = 0
        DelayMS 1000
        Out4 = 1
        Out3 = 0

Bob

thetrueman

We can write two or more statements with : separator.
However I also use it as you told and also with small delay with every statement.

12C508A runs every program but 12F508 resets the program even any output set to low. Proteus simulation is OK but real chip don't work. Thanks.

trastikata

Instead of "=1" or "=0" try PinSet and PinClear.

Maxi

I didn't know the differences, so I checked.
Thanks trastikata.

high PORTC.0
    bcf TRISC,0,0
    bsf LATC,0,0

PinSet PORTC.0
    bsf LATC,0,0

PORTC.0=1
    bsf PORTC,0,0

top204

#8
PinSet and PinClear do not alter the TRIS SFR like PinHigh and PinLow do, so they are the equivalent of Port . Pin = 1 or Port . Pin = 0. However, on devices that have LAT SFRs in an appropriate place, the compiler manipulates these instead, so it is a direct change and eliminates the dreaded Read Before Write.

Nothing has changed in the 12-bit core devices within the compiler because they are now, very, very redundant, so no advances have been made for them, and the assembler code produced is the same as it was a decade, or more, ago. Maybe a bit tidier in readability, but the same assembler code.

Use the Set_OSCCAL directive at the beginning of the code listing, so it tunes the internal oscillator with the value held within the device's code memory. Unless your programmer has deleted it.

Also, make sure your programmer is not enabling the watchdog timer. I have tried your code listing for a PIC12C508 and PIC12C508A in a programmer, and viewing the programmer's settings, the compiler is setting the config fuses correctly. i.e. Watchdog off, Code Protection on, MCLR pin active, and Internal Oscillator.

If it is working within a simulator, it means the code itself is working as expected, and if not working on a real device, it may be the fuses that are not being written correctly to the device, because the device itself has no special features that a simulator would miss. However, the proteus simulator does not always read the config fuses correctly on devices, and runs a program regardless whether it should or not.

Also, make sure you have the device's MCLR pin connected to VDD via a resistor, so it is not floating. If the MCLR pin is needed as a digital pin, set the MCLR to inactive in the config fuses.