Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC16F676 on breadboard

Status
Not open for further replies.

dhruv101

Newbie level 3
Joined
May 24, 2009
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,349
connecting ic on the breadboard

Hello all,
I am trying to test my PIC16F676 on a breadboard. I have written a simple program that sets the port RA1 as high . I tried connecting the IC to the breadboard and connecting the VCC and ground to the supply, However I did not get an output.
My code:


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

list p=16f676 ; list directive to define processor
#include <p16F676.inc> ; processor specific variable definitions

errorlevel -302 ; suppress message 302 from list file

__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT

; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.

;------------DEFINES
#define D0On B'00000010'

#define D0_1Tris B'00001000'
#define SWITCH PORTA,3


;***** VARIABLE DEFINITIONS
w_temp EQU 0x20 ; variable used for context saving
status_temp EQU 0x21 ; variable used for context saving

cblock 0x20
Flags ; LED flags
CountH ; debounce counter - MS Byte
CountL ; debounce counter - LS Byte
endc





;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program


ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register


; isr code can go here or be located as a call subroutine elsewhere


movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt


; these first 4 instructions are not required if the internal oscillator is not used
main
call 0x3FF ; retrieve factory calibration value
bsf STATUS,RP0 ; set file register bank to 1
movwf OSCCAL ; update register with factory cal value
movlw D0_1Tris ; set direction so LEDs D0 - D7 are outputs
movwf TRISA ; all others are inputs (high-z)
clrf ANSEL ; config A/D IO as Digital
movlw 00h
movwf TRISA
bcf STATUS,RP0 ; set file register bank to 0
; remaining code goes here
clrf PORTA
movlw 07h
movwf CMCON
movlw D0On ;set port RA1 high
movwf PORTA ; send data to PORTA port
;movlw 08h
;movwf PORTA

goto main


nop
nop

; initialize eeprom locations

ORG 0x2100
DE 0x00, 0x01, 0x02, 0x03


END ; directive 'end of program'
===============================================================

What kind of supporting circuitry will I require?


Thanks,
Dhruv
 

voltmeter pic16f676

Hi,

movlw D0On ;set port RA1 high
movwf PORTA ; send data to PORTA port
;movlw 08h
;movwf PORTA

goto main

In your code you set RA1 high, with b'00000010' but the next instruction you then loop to 'main' which clears all of Port A, so you will never see RA1 switched on for more than a few milliseconds.

Replace the above lines of code with this and you should see RA1 switch on


bsf PORTA,1 ; Bit Set File Port A , bit 1

loop goto loop ; just sit here looping around



Once you get this to work you can then look at using a 1 second delay so you can make the port A,1 flash a led.
 

pic16f676 voltmeter

WP100,
I tried looping around RA1 set, it worked on the evaluation kit but not on the breadboard. I guess I need some supporting circuitry for the PIC 16F676. Besides GND and VCC what other connections/supporting circuitry are involved in order to run a PIC on a breadboard. I am pretty sure the internal oscillator is being used (as per the config word).


Thanks
 

breadboard simulator code

Hi,

Well yes, it seems to be the internal oscillator so should not need any other connections.

How are you checking the portA,1 is working ? -a led or a voltmeter ?

What is your development board ? - might help if I could see its circuit.

I do not have that chip, but two things to try - assuming your breadboard is a good one with clean contacts etc -
First your pos and neg wires, if they are more than 3" long, twist them together and fit a 100nf capactitor across them on the chip pins 1 and 14
What voltage are you using -3v3 or 5v ?

If that has no effect, in the config line change the MCLRE = OFF to ON and then add a 10k resistor from the MCLRE pin 4 to positive.
That should ensure the chip runs on power up.

I will try a simulation in the mean time

Added after 3 hours 16 minutes:

Hi again,

Tried simulating your code and it seems to work with Mclre ON, which according to the data sheet will automatically pull it up, so no need for the resistor.
However could not get consistant results with Mclre =OFF ?
Still simulators are just that, not always a good test.

Your code sample seems fine to me, but something must be not right ..
give those two things I mentioned above a try, but if no go then -

Perhaps someome else can come in and see the problem - great - otherwise I would post your problem to the Microchip forum , sure they will sort out this little bug for you.
https://www.microchip.com/forums/tt.aspx?forumid=11
 

    dhruv101

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top