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.

Seven segment display using a 16f88

Status
Not open for further replies.

GreenP

New Member
Hi
I'm pretty new to these PIC things and i would like to turn two seven segment displays on, showing different numbers depending on other variables (not shown in the code below) the seven segment displays are connected to portB and the bases of two transistors are connected to bits 2 and 3 on portA, these transistors turn the cathodes for the displays on and off.

I can build the project and simulate it using MPLAB SIM, I can annimate it using the ICD2 incircuit debugger and every thing is OK as soon as I run the program in real time it stops at the goto main and
movlw b'00000000'
movwf portA
lines of code
Could anyone help as i would be very greatful
GreenP
Here is My code:

;************************************************
; ;
;30/10/07 ;
; ;
; ;
;Targeting the 16f88 device
;list p=16f88 ;
;************************************************

TMRO equ 01h ;TMRO address
status equ 03h ;status register address in bank 0
trisA equ 85h ;trisA address in bank 1
trisB equ 86h ;trisB address in bank 1
portA equ 05h ;portA address in bank 0
portB equ 06h ;portB address in bank 0
ANSEL equ 9Bh
PCL equ 02h ;program counter address
OPTION_REG equ 81h ;options register sddress
OSCCON equ 8Fh
DELAYONE equ 20h ;address in general purpose register for 100 counts for the delay


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

org 0h ;?
goto START
org 10h ;?

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

INT
;declaring the ports



bsf status,5 ;setting bit 5 in status register1 so the program is looking at memory bank 1

clrf ANSEL
clrf trisA
clrf trisB


movlw b'00100000' ;putting the literal value 00000000 into the working register
movwf trisA ;moving the value 00000000 into trisB sets up portB as all outputs

movlw b'00000000' ;putting the literal value 00000 into the working rerister
movwf trisB ;moving the value 00000 into trisA sets up portA as all outputs


;setting up the options register for TMRO

movlw b'10000000' ;moving the literal value into the working register and then into the
movwf OPTION_REG ;options register so as to set up the prescaler for TMRO

movlw b'01101000'
movwf OSCCON

STABLE

btfss OSCCON,2 ; INTOSC frequency stable?
goto STABLE ; no, branch and wait

bcf status,5



return

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



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





DELAY

clrf portA
clrf portB


movlw b'00000011' ;moving the literal value decimal 100 into the working register
movwf DELAYONE ;and then into the count 100 register so timer can count up to 100

bsf portA,0

call DISPLAY_1

DELAY_1
decfsz DELAYONE
goto DELAY_1

clrf portA
clrf portB


movlw b'00000011' ;moving the literal value decimal 100 into the working register
movwf DELAYONE ;and then into the count 100 register so timer can count up to 100

movlw b'00000010'
movwf portA

call DISPLAY_2
DELAY_2
decfsz DELAYONE
goto DELAY_2

clrf portA
clrf portB



return
DISPLAY_1

movlw b'1101111' ;code for 0
movwf portB

return


DISPLAY_2

movlw b'1111101' ;code for 6
movwf portB

return

START

call INT

MAIN
call DELAY
goto MAIN

END
 
You might have a look at my seven segment tutorial - sounds like it will do just what you want!.

BTW, if you post code use the 'code' button to maintain it's formatting (it's on the 'advanced' setting.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top