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.

Problem with PIC16f72

Status
Not open for further replies.

chris92

New Member
Hello Pals. I built a PIC circuit on a vero board to show 9,8,7,6...1,0 on a seven segment display. I tested the code with proteus and it was perfect but on the circuit it is not. I have checked the respective voltage of every connection and everything is perfect too but when i connect the PIC and check the Voltage of PORTB which is where I connected the 7segment, it reads just 0.03-0.06volts which cannot power the display. Please does anyone have an idea of what I did wrong. Thanks a lot
 
K............ Dats the schema
and this is d code:,
.......

Code:
    list        p=16f72        ; list directive to define processor
    #include    <p16f72.inc>    ; processor specific variable definitions
   
    __CONFIG   _CP_OFF & _WDTEN_OFF & _BODEN_OFF & _PWRTEN_ON & _HS_OSC

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












;**********************************************************************
RESET_VECTOR    CODE    0x000        ; processor reset vector
    goto    start            ; go to beginning of program

MAIN    CODE

start

COUNT1 EQU 3FH
COUNT2 EQU 3DH
PORTA EQU 05H
PORTB EQU 06H
PORTC EQU 07H
TRISA EQU 85H
TRISB EQU 86H
TRISC EQU 87H
STATUS EQU 03H

BSF STATUS,5
CLRF TRISA
CLRF TRISB
BCF STATUS,5
CLRF PORTA
CLRF PORTB


;09
MOVLW 67H
MOVWF PORTB
CALL DELAY
CLRF PORTB
;08
MOVLW 7FH
MOVWF PORTB
CALL DELAY
CLRF PORTB
;07
MOVLW 07H
MOVWF PORTB
CALL DELAY
CLRF PORTB
;06
MOVLW 7DH
MOVWF PORTB
CALL DELAY
CLRF PORTB
;05
MOVLW 6DH
MOVWF PORTB
CALL DELAY
CLRF PORTB
;04
MOVLW 66H
MOVWF PORTB
CALL DELAY
CLRF PORTB
;03
MOVLW 4FH
MOVWF PORTB
CALL DELAY
CLRF PORTB
;01
MOVLW 5BH
MOVWF PORTB
CALL DELAY
CLRF PORTB
;00
MOVLW 06H
MOVWF PORTB
CALL DELAY
CLRF PORTB

MOVLW 3FH
MOVWF PORTB
CALL DELAY
CLRF PORTB
nop
DELAY
LOOP2
DECFSZ COUNT1,1
GOTO LOOP2
DECFSZ COUNT2,1
GOTO LOOP2
RETURN





    END                       ; directive 'end of program'
 

Attachments

  • schem.png
    schem.png
    10.5 KB · Views: 227
What is the clock frequency?
Your delay is probably too short.
With 20MHz clock the delay is about 0.04 seconds and with 4MHz about 0.2 seconds.
Should the program continue or stop when all numbers have been shown, now it goes haywire after one round.
The code needs goto start or forever loop before delay.
 
What is the clock frequency?
Your delay is probably too short.
With 20MHz clock the delay is about 0.04 seconds and with 4MHz about 0.2 seconds.
Should the program continue or stop when all numbers have been shown, now it goes haywire after one round.
The code needs goto start or forever loop before delay.
I used 4MHz and the program should stop. The program is working fine in proteus
 
The LED's have a current consumption just as any other LED... Read the datasheet and find out what that is.

If you are powering your pic with 5V I suggest running your LED's a 10mA so try using 270 / 330 ohm resistors.. It is also good practice to drive the cathode / anode with a transistor...
 
Ok but most simple examples i ve seen did not have to use these components. I just wish I could see something working and it would be good start for me. I ve even tried just putting a led on and it didnt work. The voltage on the data pins are just too low to even power anything, about 0.03v
 
If you have tried to run a normal LED from the pin of a micro without the current limiting resistor, you will have damaged the micro... A pic can only supply 25mA maximum.. The LED without the current limit will draw tons more than that!!
 
Ok sir, i really appreciate your help, Rogers. I guess the micro is still fine cause the PICKit still detects, reads, writes and verifies it.

Am sorry to ask but is it not contradicting to limit a current with resistors and at the same time trying to amplify it with a transistor.

Thanks
 
Ok sir, i really appreciate your help, Rogers. I guess the micro is still fine cause the PICKit still detects, reads, writes and verifies it.

Am sorry to ask but is it not contradicting to limit a current with resistors and at the same time trying to amplify it with a transistor.

No, you're not 'amplifying' you're simply switching - assuming you're multiplexing LED's then each segment takes 10mA or so (with the correct resistors). this means the common connection has to supply 7x10mA or 70mA - which is why it's best to use a switching transistor to do it.

However, despite Ian's pessimism, it's VERY, VERY difficult to damage a PIC - but you should certainly include current limiting resistors to the LED's, it's VERY, VERY important.

I would suggest you start 'simpler', get something working before you try and complicate matters - have a look at my tutorials, they start of by flashing a single LED, and work up from there. So get something like that working first.

You also didn't post much on the schematic at all, such as no clock components or supply decouplers
 
Just because it seems fine when programming, doesn't mean it is fine..

Take portb for example... As an output there are latches that may / may not be damaged.. BUT!! as an input it may still work aokay...

Even as an output.. If the top fets are blown, it will still be able to function as a current sink!!!

(Sorry Nigel... I was tying whilst you posted )
 
I used 4MHz and the program should stop. The program is working fine in proteus
Do you use crystal oscillator?
In config-word you have specified HS oscillator, should be XT for 4MHz crystal
Are you using voltage supply from PICkit2?
If you want the program to stop after running once, you need a sleep instruction or label goto label before delay routine.
Could you post a real schematic, not a schema from Proteus.
 
Last edited:
Chris you add the resistor and cap to MCLR as in the data sheet ? Did you update to MPLAB 8?
I had issues with downloading the MPLAB update but I ll still contine later and I added the resistor and cap but it still didnt work.
 
Just because it seems fine when programming, doesn't mean it is fine..

Take portb for example... As an output there are latches that may / may not be damaged.. BUT!! as an input it may still work aokay...

Even as an output.. If the top fets are blown, it will still be able to function as a current sink!!!

(Sorry Nigel... I was tying whilst you posted )
So I gues I should change it?
 
No, you're not 'amplifying' you're simply switching - assuming you're multiplexing LED's then each segment takes 10mA or so (with the correct resistors). this means the common connection has to supply 7x10mA or 70mA - which is why it's best to use a switching transistor to do it.

However, despite Ian's pessimism, it's VERY, VERY difficult to damage a PIC - but you should certainly include current limiting resistors to the LED's, it's VERY, VERY important.

I would suggest you start 'simpler', get something working before you try and complicate matters - have a look at my tutorials, they start of by flashing a single LED, and work up from there. So get something like that working first.

You also didn't post much on the schematic at all, such as no clock components or supply decouplers
So I either use the resistor or transistors.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top