Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

10F206 help

Status
Not open for further replies.

Lighty

New Member
Hi all

I've done a little programiing of the 16f628/A and can get my way around with the basics, using GCBasic.

Wanting to simplify my circuits so I bought a 10F206 to make 2 led flash, using GP0 and GP1 to drive the LEDs.

I'm using a PICKit 2 prcgrammer with the PICKit 2 software.

But I keep getting a message referring to the "osccal", if tried setting (using the PICKit software) to verious setting, but still nothing

When I add "#OSCCAL 11111110" to the txt file, on compiling it I get a error message "Configuration setting not valid: CAL11111110_OSC"

Please Help

Code:
#chip 10f206,4
#config INTRC_OSC

#DEFINE BLUE PortGP.0
#DEFINE WHT PORTGP.1


Main:
SET WHT ON
WAIT 1 S
SET WHT OFF
WAIT 1 S
SET BLUE ON
WAIT 1 S
SET BLUE OFF 
WAIT 1 S
goto main

A Copy of the .ASM file

Code:
;Program compiled by Great Cow BASIC (0.9 10/2/2007)
;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
;check the documentation or email hconsidine@bigpond.com.

;********************************************************************************

;Set up the assembler options (Chip type, clock source, other bits and pieces)
 LIST p=10F206, r=DEC
#include <P10F206.inc>
 __CONFIG _INTRC_OSC & _WDT_OFF & _MCLRE_OFF

;********************************************************************************

;Set aside memory locations for variables
DELAYTEMP	equ	8
DELAYTEMP2	equ	9
DELAYTEMP4	equ	10
PORTGP	equ	11
SysWaitTempMS	equ	12
SysWaitTempS	equ	13

;********************************************************************************

;Jump to initialisation code when PIC is reset
	ORG	0
	call	INITSYS
	goto	SystemInitialise

;********************************************************************************

;Various initialisation routines, automatically called by GCBASIC
SystemInitialise

;********************************************************************************

;Start of the main program
MAIN		
	bsf	PORTGP,1
	movlw	1
	movwf	SysWaitTempS
	call	Delay_S
	bcf	PORTGP,1
	movlw	1
	movwf	SysWaitTempS
	call	Delay_S
	bsf	PORTGP,0
	movlw	1
	movwf	SysWaitTempS
	call	Delay_S
	bcf	PORTGP,0
	movlw	1
	movwf	SysWaitTempS
	call	Delay_S
	goto	MAIN
BASPROGRAMEND		
	sleep	
	goto	$
		
;********************************************************************************
;Subroutines included in program
;********************************************************************************
		
DELAY_MS		
DMS_START		
	movlw	10
	movwf	DELAYTEMP2
DMS_OUTER		
	movlw	33
	movwf	DELAYTEMP
DMS_INNER		
	decfsz	DELAYTEMP, F
	goto	DMS_INNER
	decfsz	DELAYTEMP2, F
	goto	DMS_OUTER
	decfsz	SysWaitTempMS, F
	goto	DMS_START
	retlw	0
		
;********************************************************************************
		
Delay_S		
DS_START		
	movlw	10
	movwf	DELAYTEMP4
DS_OUTER		
	movlw	100
	movwf	SysWaitTempMS
	call	Delay_MS
	decfsz	DELAYTEMP4, F
	goto	DS_OUTER
	decfsz	SysWaitTempS, F
	goto	DS_START
	retlw	0
		
;********************************************************************************
		
INITSYS		
	clrf	GPIO
	movlw	7
	movwf	CMCON0
	retlw	0
		
;********************************************************************************

 END
 
Last edited:
Them Chips are harder to program then the 16f628a LOL
All you need is to add
Code:
RESET   CODE    0x1FF            ; processor reset vector
        res     1               ; holds movlw with factory RC cal value

MAIN    CODE    0x000           ; effective reset vector
        movwf   OSCCAL          ; update OSCCAL with factory cal value
You have to add the .lkr for your chip to your project file in mplab

I never had much luck like this
Code:
;Set aside memory locations for variables
DELAYTEMP	equ	8
DELAYTEMP2	equ	9
DELAYTEMP4	equ	10
PORTGP	equ	11
SysWaitTempMS	equ	12
SysWaitTempS	equ	13
; I do it like this 
;Set aside memory locations for variables
UDATA
DELAYTEMP	res 1
DELAYTEMP2	res 1
DELAYTEMP4	res 1
PORTGP	        res 1
SysWaitTempMS  res 1	
SysWaitTempS   res 1
 
Last edited:
The osccal value is stored in location 0x1ff as a movlw instruction and is sometimes accidentally overwritten. If you download and install the stand alone PK2 software it has the ability to recalculate the value.

Looking at the asm code, GCB ignores the calibration value and so it is (probably) just the PK2 software giving a warning.

Mike.
 
Last edited:
Basic not good for them chips any way it never set them right and it uses to much ram.
You know that MIKE
Never used it Great Cow BASIC But picbasic pro tell you to use assembly for most baseline chips
 
Ok, Found a STUPID mistake, had the Vdd on the Vss pin and Vss on the N/C...... This what happens when you rush something.....

Rectified that and it now writes without any errors or problems, but it still doesn't make the LEDs flash?
 
Rectified that and it now writes without any errors or problems, but it still doesn't make the LEDs flash?
Unlike the midrange and 18f Pics, GCBasic does not set the TRIS GPIO register (by default) on the baseline PICS. Also the TRIS has to be set all at once on the baseline devices. Just include the following before main, and check the assembly to see what I mean.

Code:
dir GPIO b'001000'

You have to like the 94 page datasheet for 10f's. Haven't tried anything useful yet with the 10f's, they would be tricky for sure with a high level language. Still room though for more stuff in the program, as from the GCBasic listing file:

Code:
Program Memory Words Used:    50
Program Memory Words Free:   462

Looks like a soft PWM rgb led program fits easily in program space, but you blow through nearly all your variables/ram, 21 used out of the 24 available. So there you go, one would need to get creative, or use some assembler as mentioned earlier.

P.S. I have never understood the angry emoticon in the thread description, except maybe in Chat. One is left with the impression that no help has been supplied, or problem not solved, before the discussion even starts. Please edit, or not, to thumbs up or smiley face if a solution has been supplied. Done venting.
 
Last edited:
Thanks Nickelflippr, Just get frustrated with myself, everyones help is appriciated :)

I found the "dir GPIO b'001000' in abother thread and it works, but not properly....if that makes sense?

This is the code, I know its long and drawn out, but it was for "learning purposes", but I found the the "pattern" on the GPIO.1 would often bypass/skip/not flash, almost like it "crashes, but the sequence on GPIO.0 would always run without fault.....

Code:
#chip 10f206, 4 
#config INTRC_OSC

dir GPIO b'001000' 
#DEFINE LED1 GPIO.0 
#DEFINE LED3 GPIO.1

Main: 
set LED1 ON
wait 3 10MS
set LED1 OFF
Wait 3 10MS
Set LED1 ON
wait 3 10MS
set LED1 OFF
Wait 3 10MS
set LED1 ON
wait 3 10MS
set LED1 OFF
wait 10 10MS    ;====
set LED1 ON
wait 3 10MS
set LED1 OFF
Wait 3 10MS
Set LED1 ON
wait 3 10MS
set LED1 OFF
Wait 3 10MS
set LED1 ON
wait 3 10MS
set LED1 OFF
wait 10 10MS    ;====
set LED1 ON
wait 3 10MS
set LED1 OFF
Wait 3 10MS
Set LED1 ON
wait 3 10MS
set LED1 OFF
Wait 3 10MS
set LED1 ON
wait 3 10MS
set LED1 OFF
wait 10 10MS ; ================
set LED3 ON
wait 3 10MS
set LED3 OFF
wait 3 10MS
set LED3 ON
wait 3 10MS
set LED3 OFF
wait 3 10MS
set LED3 ON
wait 3 10MS
set LED3 OFF
wait 10 10MS ;====
set LED3 ON
wait 3 10MS
set LED3 OFF
wait 3 10MS
set LED3 ON
wait 3 10MS
set LED3 OFF
wait 3 10MS
set LED3 ON
wait 3 10MS
set LED3 OFF
wait 10 10MS ; ====
set LED3 ON
wait 3 10MS
set LED3 OFF
wait 3 10MS
set LED3 ON
wait 3 10MS
set LED3 OFF
wait 3 10MS
set LED3 ON
wait 3 10MS
set LED3 OFF
wait 10 10MS
goto Main

I though I would use the 10F206 due to the low pin count and space saving, but think I'm probably better off just sticking to the 16F628?
 
Thanks Nickelflippr, Just get frustrated with myself, everyones help is appriciated :)

I found the "dir GPIO b'001000' in abother thread and it works, but not properly....if that makes sense?
No, sounds like a hardware problem like a bad solder joint, or poor connection on breadboard, or?

This is the code, I know its long and drawn out, but it was for "learning purposes", but I found the the "pattern" on the GPIO.1 would often bypass/skip/not flash, almost like it "crashes, but the sequence on GPIO.0 would always run without fault.....
Use #defines for your wait periods, so that you don't have to go back and change every last one of the wait periods if the pattern doesn't look right. Also use loops for code sequences that repeat themselves.

Code:
#define pinwait wait 3 10ms
#define pinchange wait 7 10ms  ;i.e 100ms - 30ms
...
...
Main:
For blinkLED1 = 1 to 3
    Pulseout LED1, pinwait
    pinwait
next
pinchange
For blinkLED3 = 1 to 3
    Pulseout LED3, pinwait
    pinwait
next
pinchange
goto Main

I though I would use the 10F206 due to the low pin count and space saving, but think I'm probably better off just sticking to the 16F628?
If it's something simple, then why not 10F? There is no good answer, without knowing the final code requirements, or expectations. Just keep a close eye on the variable count in the .lst file. With this code there are 9 more variables, and 445 words of memory to spend............hehe. Good luck.

be80be said,
Do it in assembly it's not that hard . Go here and read his howto Gooligum Electronics
For sure, that's the best link ever for the baseline devices.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top