News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Programming a 10F200

Started by Fanie, Mar 16, 2025, 07:53 PM

Previous topic - Next topic

Fanie

Good grief !  How difficult can this be  :'(

I'm trying to get this humungous pic to do something.
Can someone tell me why this code is not working please ?
All it must do is to trigger an output low once and never again.

Device = 10F200   
 Declare Xtal = 4 
'
 Config INTRC_OSC, CP_OFF, WDT_OFF, MCLRE_OFF
 
 TRIS GPIO = %00000000            ' All Outputs

'----------------------------------------------------------------------------
' The main program starts here
'----------------------------------------------------------------------------

Start:
    High GPIO.2
    DelayMS 1000
    Low GPIO.2
    DelayMS 500
    High GPIO.2
Start2:
    DelayMS 1000
    GoTo Start2
   
    End

Fanie

MPLAB IPE also pops up per occasion and tell me the PicKit4 cannot program the 10F200, but when I select "all families" of the pics, then it does program the 10F200.

Another frustration is it programs one pic -

QuoteCalculating memory ranges for operation...

Erasing...

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x47
configuration memory
Programming/Verify complete
2025-03-16 21:49:05 +0200 - Programming complete
***   Hold In Reset mode is enabled   ***
and the bar on the programmer remains yellow and MPLAB IPE does not react.
If I restart the IPE again I can program one more pic.

trastikata

#2
Hello Fanie,

if you read back the PIC memory with MPLAB after flashing, does it show successful memory update?

P.s. if you keep the device connected with the programmer, then the PIC might be held in reset state by MPLAB.

Fanie

It says

QuoteThe following memory area(s) will be read:
program memory: start address = 0xff, end address = 0xff
program memory: start address = 0x0, end address = 0xff
configuration memory
User Id Memory
Read complete

and when I verify it says

QuoteThe following memory area(s) will be verified:
program memory: start address = 0x0, end address = 0xfe
configuration memory
User Id Memory
Verification successful.

Fanie

#4
Does the pic's setup and my code looks correct ?

I have an LED on the output which is supposed to be on for a second, the go off for half a second, and then remain on as long as power to the board.

I've programmed these before without a problem... Do you think I can find the code.

I disconnect the programmer and connect the micro to 5V.

trastikata

#5
I think this part of the code is incorrect:
TRIS GPIO = %00000000            ' All Outputs

should be:
TRISIO = %00000000            ' All Outputs

also OPTION.5 should be 0 thus:

OPTION.5 = 0
TRISIO = %00000000

RGV250

Hi,
A couple of thoughts, have you tried using another pin, also it should not make any difference but try using PortB instead of GPIO.
I do not think you need the
Start2:
    DelayMS 1000
    GoTo Start2

Bob

trastikata

Device = 10F200   
 Declare Xtal = 4
'
 Config CP_OFF, WDT_OFF, MCLRE_OFF

OPTION_REG.5 = 0
TRISIO = %00000000            ' All Outputs
 

'----------------------------------------------------------------------------
' The main program starts here
'----------------------------------------------------------------------------

Start:
    High GPIO.2
    DelayMS 1000
    Low GPIO.2
    DelayMS 500
    High GPIO.2
Start2:
    DelayMS 1000
    GoTo Start2
   
    End


Fanie

It seems it does not recognize portB, I get no compile errors but the text does not indicate as it does with GPIO

Still as dead as a doornail.

TRISIO = %00000000            ' All Outputs - makes no difference

What is OPTION.5 = 0 ?

Fanie


Fanie

#10
WORKING !!
I suspect the problem was the OPTION_REG.5 = 0 where 0 = Transition on internal instruction cycle clock, FOSC/4

Thank you, you guys are awesome !

And btw, this pic is so small I wasn't sure if it was going to fit in the 8-bit section...

trastikata

Quote from: Fanie on Mar 16, 2025, 09:27 PMWORKING !!
I suspect the problem was the OPTION_REG.5 = 0 where 0 = Transition on internal instruction cycle clock, FOSC/4

Glad it worked out.

There are couple of registers taking precedence over the TRIS register for GPIO.2 pin and OPTION_REG.5 is one of them. By default the OPTION_REG.5 is set to 1, thus needs to be set to 0 to "release" the functionality for the GPIO.2

Fanie

QuoteBy default the OPTION_REG.5 is set to 1, thus needs to be set to 0 to "release" the functionality for the GPIO.2

That is how I understood when checking in the data sheet.  Thank you kindly.

The little board is a trigger for another board.  The customer wants it to start a process each time the power goes on.  The original board was required to be triggered with a push button switch, but now it must be adapted for all other kinds of variations.  Customers. ;D

Again, every one's prompt help is much appreciated.

Atlete.jpg
Camera man running ahead of the 100m sprinters with his camera to film them...
He passed over the finish line ahead of them too   8)

SebaG

No offense, but that's shooting a fly with a cannon :) In the past we would use a differentiator or a monostable generator. Today your method is probably simpler and cheaper. The question is whether it is as reliable.

rick.curl

Quote from: SebaG on Mar 26, 2025, 12:47 PMNo offense, but that's shooting a fly with a cannon :) In the past we would use a differentiator or a monostable generator. Today your method is probably simpler and cheaper. The question is whether it is as reliable.
That's true- but I learned a lesson a while back.  My company made high voltage test equipment that had big "warning" LEDs on top.  One customer said he would only buy the equipment if the warning lights flashed. My first thought was to lay out a little PCB with a 555 timer on it, but I decided to use a 10F200 instead. As luck would have it, the customer came back a month later and said he needed a double flash! We loaded up new firmware and sold him $30,000 worth of new test equipment!

I admit it was dumb luck, but it worked out great.

-Rick

Fanie

#15
Quote from: SebaG on Mar 26, 2025, 12:47 PMNo offense, but that's shooting a fly with a cannon :) In the past we would use a differentiator or a monostable generator. Today your method is probably simpler and cheaper. The question is whether it is as reliable.
Can you do better than with one small component ?
Let me add.  The pic also provides a 1 sec delay before it fires the rest of the circuitry with a 250ms once off.

Stephen Moss

Quote from: rick.curl on Mar 26, 2025, 04:46 PMMy first thought was to lay out a little PCB with a 555 timer on it, but I decided to use a 10F200 instead.
A PIC would have been my prefernce as...
  • I always struggles with 555 timers, either they work 1st time or are a total pain in the ass to get running.
  • A PIC is more accurate, even on the internal ocillator it is <1%, where as a 555 is far less accurate due to the capacitor tollernece.
  • A PIC cost about the same as a 555, but is overall chaper as no additional componets are required & less board space, and
  • A PIC is more versatile/accurate when setting a pulse width.

John Lawton

Given the amount of time people have been discussing this on the forum I could have built a 555 timer and had some lunch afterwards. I guess I'm a bit old-school.

:)

John

Fanie

Quotecapacitor tollernece
They say people who cannot spell are well endowed.  ::)
QuoteGiven the amount of time
I used a pic, that is why we have the time  ;)