• 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.

PIC Micro Choice

Status
Not open for further replies.

AtomSoft

Well-Known Member
Hey guys im looking for a solution here. I have a small project i want to do. It will require the control of 2 transistors and 1 button.

So i need a minimum of 3-4 i/o pins. i would like to use a 8pin package (DIP or SOIC).

I need it to run off of 2 AA batteries.

I need to have it with a internal OSC to insure part count is low.

And thoughts? Thanks for taking the time to at least read this :D
 

AtomSoft

Well-Known Member
Thanks i just ordered 3 of these. Thanks a bunch again.
I havent been on these for a while but what can i use to program these except asm?

Is there a Basic or C i can use for 12F pics?
 

eng1

New Member
Thanks i just ordered 3 of these. Thanks a bunch again.
I havent been on these for a while but what can i use to program these except asm?

Is there a Basic or C i can use for 12F pics?

BoostC, mikroC or Hi-Tech PIC C for example.
 

Mike - K8LH

Well-Known Member
Man you're fast. I didn't have time to pass along my recommendations. Anyway, you've four four choices; 12F629, 12F635, 12F675, and 12F683. The 12F635 and 12F683 have an 8 MHz INTOSC. The 12F683 is my favorite because it's pretty much "full blown" as far as 2K memory space, full compliment of timers, CCP module, etc.

Almost forgot. You've got to look into BoostC for the 12F/16F parts.

Good luck. Mike
 
Last edited:

AtomSoft

Well-Known Member
ok trying some asm right now .. no errors. but hard to test since its so fast lol:

Code:
	list      p=16f627A           ; list directive to define processor
	#include <p16F627A.inc>       ; processor specific variable definitions

	errorlevel  -302              ; suppress message 302 from list file

	__CONFIG   _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT 



;***** VARIABLE DEFINITIONS
d1        EQU     0x7E        ; variable used for context saving 
d2        EQU     0x7F        ; variable used for context saving

	ORG     0x000             ; processor reset vector
	BSF PCON, 3
	MOVLW 0x07 ;Turn comparators off and
	MOVWF CMCON ;enable pins for I/O
	BCF STATUS, RP0 ;
	BCF PORTB, 7 ;01pp pppp 11pp pppp
	BSF STATUS, RP0 ;
	BCF TRISB, 7 ;10pp pppp 11pp pppp
	BCF TRISB, 6 ;10pp pppp 10pp pppp
main
	BSF		PORTB,0
	call    Delay
	BCF 	PORTB,0
	call    Delay
	goto	main		  ;loop forever, remove this instruction, for test only


Delay
	movlw	0x5e         ;0x3E
	movwf	d1
	movlw	0xeb         ;0x9D
	movwf	d2
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	Delay_0
	goto	$+1
	nop
	return

	END
Got the above working now
 
Last edited:

AtomSoft

Well-Known Member
BoostC is awesome also!

Code:
#include <system.h>

#pragma DATA _CONFIG, _CP_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _LVP_OFF
#pragma CLOCK_FREQ 4000000
void main()
{
	char t = 150;

	cmcon = 0x07;
	pcon.OSCF = 1;
	trisb = 0x00;

	while(1){
		set_bit( portb, 0 );
		delay_ms(t);
		clear_bit( portb, 0 );
		delay_ms(t);
	}

}
 

AtomSoft

Well-Known Member
Cow Basic is wierd lol i changed or created a new compile bat to make it simpler:

Code:
@ECHO OFF
E:
cd \PROGRA~1\GCBASIC

GCBASIC /NC %1 /O:%1.asm 
PAUSE
This will compile your file and place it in same directory as original.

Then u would use mplab to load it i assume.
 

AtomSoft

Well-Known Member
ok issue here. Im trying ASM again but for a 10F206. I think i got the power and connection ok
since it programs correctly but this code doesnt blink a led for some reason:

Code:
	list      p=10F206            ; list directive to define processor
	#include <p10F206.inc>        ; processor specific variable definitions

	__CONFIG  _IntRC_OSC & _MCLRE_ON & _CP_OFF & _WDT_OFF

d1	equ	8
d2	equ	9

	ORG     0x000            
	movwf   OSCCAL            ; update register with factory cal value 

start	
	movlw   0x00	
	TRIS	GPIO
MAIN		
	bsf	    GPIO,2
	call	Delay300ms

	bcf	    GPIO,2
	call	Delay300ms

	goto	MAIN

Delay300ms
	movlw	0x5E
	movwf	d1
	movlw	0xEB
	movwf	d2
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	Delay_0
	goto	$+1
	nop
	retlw	0

 END
 

geko

Active Member
The 10F206 has a comparator module that is enabled at reset.

You need to turn it off to use GP2 as digital I/O

Edit: although according to the datasheet the output isn't enabled on GP2 at reset

Just tested the code you posted using the Oshonsoft PIC10F simulator and it toggles GP2 correctly
 
Last edited:

AtomSoft

Well-Known Member
not working still
Code:
	list      p=10F206            ; list directive to define processor
	#include <p10F206.inc>        ; processor specific variable definitions

	__CONFIG  _IntRC_OSC & _MCLRE_ON & _CP_OFF & _WDT_OFF

d1	equ	8
d2	equ	9

	ORG     0x000            
	movwf   OSCCAL            ; update register with factory cal value 

start	
	movlw	7
	movwf	CMCON0
	movlw   0x00	
	TRIS	GPIO
MAIN		
	bsf	    GPIO,2
	call	Delay300ms

	bcf	    GPIO,2
	call	Delay300ms

	goto	MAIN

Delay300ms
	movlw	0x5E
	movwf	d1
	movlw	0xEB
	movwf	d2
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	Delay_0
	goto	$+1
	nop
	retlw	0

 END
 

AtomSoft

Well-Known Member
yeah 0x07 = 0b00000111
PIN7 = 0
PIN6 = 0
PIN5 = 0
PIN4 = 0
PIN3 = 0
PIN2 = 1
PIN1 = 1
PIN0 = 1


Even this didnt help tho :
Code:
CLRF	    CMCON0
 
Last edited:

geko

Active Member
bug in the Oshonsoft PIC10F simulator

Tested it on a 'real' 10F206 and it doesn't work as you found


You need to add this to disable T0 clock source on GP2

Code:
 movlw ~(1<<T0CS)
 option
 

eng1

New Member
yeah 0x07 = 0b00000111
PIN7 = 0
PIN6 = 0
PIN5 = 0
PIN4 = 0
PIN3 = 0
PIN2 = 1
PIN1 = 1
PIN0 = 1


Even this didnt help tho :
Code:
CLRF        CMCON0
Yes, you cleared it :) Take a look at the T0CS bit of the OPTION register. I don't remember its value upon reset, but if it is 1, it will override the TRIS settings on GP2. Does your program work on GP1 without changes?
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top