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.

How to start PIC16F676 ...??

Status
Not open for further replies.

koolguy

Active Member
Hi,

I want to start PIC16F676 with blinking LED projects on hardware with assembly lang.
so, please post schematic and procedure to make this projects....
i am using this **broken link removed**
Thanks
 
Hi,

As Ian says use Nigels tutorials, here is lesson 1, led flasher, but modified for your chip.

Just note the differences and then you can apply then to the rest of his code examples.

The picture shows how to wire the led, though you must add +5v and 0v .




Code:
;Tutorial 1.2 - Nigel Goodwin 2002  ; MODIFIED FOR PIC16F676

	LIST	p=16F676		;tell assembler what chip we are using
	include "P16F676.inc"	;include the defaults for the chip
	__config 0x3D14			;sets the configuration settings (oscillator type etc.)
							; HERE SET TO INTERNAL OSCILLATOR 4MHZ

	cblock 	0x20 			;start of general purpose registers
		count1 			;used in delay routine
		counta 			;used in delay routine 
		countb 			;used in delay routine
	endc
	
	org	0x0000			;org sets the origin, 0x0000 for the 16F628,
					;this is where the program starts running	

	bcf 	STATUS,RP0 	;Bank 0
	clrf 	PORTA 		;Init PORTA
	movlw	05h 		;Set RA<2:0> to 
	movwf	CMCON 		;digital I/O
	bsf 	STATUS,RP0 	;Bank 1
	clrf	ANSEL 		;digital I/O
	movlw 	00h 		; 
	movwf 	TRISA 		;as outputs

   	movlw 	b'00000000'	;set PortC all outputs
   	movwf 	TRISC
	movwf	TRISA		;set PortA all outputs
	bcf		STATUS,	RP0	;select bank 0

Loop	
	movlw	0xff
	movwf	PORTA			;set all bits on
	movwf	PORTC
	nop				;the nop's make up the time taken by the goto
	nop				;giving a square wave output
	call	Delay			;this waits for a while!
	movlw	0x00
	movwf	PORTA
	movwf	PORTC			;set all bits off
	call	Delay
	goto	Loop			;go back and do it again

Delay	movlw	d'250'			;delay 250 ms (4 MHz clock)
	movwf	count1
d1	movlw	0xC7
	movwf	counta
	movlw	0x01
	movwf	countb
Delay_0
	decfsz	counta, f
	goto	$+2
	decfsz	countb, f
	goto	Delay_0

	decfsz	count1	,f
	goto	d1
	retlw	0x00

	end
 
How to start MAP lab IDE v8.33 for PIC16F676..?

Hello,

I am new to map lab i want to know how to start it...
please help me to start with PIC 16f676 with blinking LED like 555 chip...as table.


thanks
 
Its very easy.... Boot up MPLAB IDE... file menu... project / project wizard... follow the instructions.... Are you going to program in assembler or C?

I have Nigel Goodwin's tutorials converted to C... So you can copy Nigel's or my tutorials ( they are for the pic16f628 / a but with subtle changes you can compile / assemble on to the pic16f676).

Both links are on my signature.
 
Last edited:
Hi,

i was working on Oshon simulator with LED blinking the code is working fine.
but i have no idea how to add oscillator option for it , please tell how to use oscillator whether its crystal or code or RC..?
 
Hi,

As Ian says use Nigels tutorials, here is lesson 1, led flasher, but modified for your chip.

Just note the differences and then you can apply then to the rest of his code examples.

The picture shows how to wire the led, though you must add +5v and 0v .

Hi, i have oshon simulator in it this code shows 12 error..
If i want to test it in MAplab ide 8.33 please tell how to do it??
 
Ritesh.... You can copy the above code (provided by Wp100) and paste it into a new project in MPLAB.

Have you ever created a new project in MPLAB before?

If No..

1) Open MPLAB.
2) On the menu select "Project/Project Wizard".
3) Click "next".
4) Select YOUR chip. then "next"
5) Select "Microchip MPASM Toolsiute" From the combo box. Select "next".
6) Browse for a folder ( create one from the common dialog box that opens ). Select "next".
7) Add files ( in your case, skip this and select "finish").
8) Once the project is ready, select "New file" from the toolbar.
9) Paste the code into this page, then "Save As" an ".asm" file into your project directory.
10) In the MCW window on the Left... Right Click on the "source files" and select "Add Files".
11) Once the file has been added, Select "Project/ Build All" from the menu.
12) All being well there should be a hex file in the project directory.
 
Have you ever created a new project in MPLAB before?

No, I have never used MAP LAB IDE...!!

If No..

1) Open MPLAB.
2) On the menu select "Project/Project Wizard".
3) Click "next".
4) Select YOUR chip. then "next"
5) Select "Microchip MPASM Toolsiute" From the combo box. Select "next".
6) Browse for a folder ( create one from the common dialog box that opens ). Select "next".
7) Add files ( in your case, skip this and select "finish").
8) Once the project is ready, select "New file" from the toolbar.
9) Paste the code into this page, then "Save As" an ".asm" file into your project directory.
10) In the MCW window on the Left... Right Click on the "source files" and select "Add Files".
11) Once the file has been added, Select "Project/ Build All" from the menu.
12) All being well there should be a hex file in the project directory.

OK, after this i got 4 file as .err, .lst, .O and .hex the required file!!
please tell the use of these three files??

and does MAPLAB do more function than converting assembly to HEX??
 
Hi,

Iwrote this code:->
but tested in OSHON simulator with the keypad and code are not working .....can we check this in maplab?? If yes please tell how?
BCF STATUS,RP0
MOVLW 0H
MOVWF PORTB ; portb as output
MOVLW 0FFH
MOVWF PORTA ; porta as input
BSF STATUS,RP0
MOVLW 00H
MOVWF TRISB
MOVLW 0FFH
MOVWF TRISA
BCF STATUS,RP0

START:

btfss PORTA,1 : test bit 1
call delay

GOTO START

delay:
movlw 0ffh
movwf portb
movlw 0fh
movwf 021h
dECfsz 021h,0
clrf portb
RETURN
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top