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.

microchip application A590 /display is ok now

Status
Not open for further replies.

prosound90

New Member
hi

its not the first time i use one of the application notes from microchip and i find that the code has bugs and it dose'nt work.

this time its the AN690 i wonder if anyone tryed to use this code ,

this is what i did i made the PCB for there schematic but i used 16F877

insted of the 16C54 , i modefied the code to work with the mid range PIC

but the display never worked right, after i got frustrated with the code

i thought iam doing something wrong,

i programed a PIC16C54 and wired it up to the display , and just like i thought it did not work .!!!

i dont know why they do that ......are they expecting us to troubelshoot the code???.


any way can someone please take alook at the code and find the bugs

or mabe someone has aalready constructed the AN690 and found the erros.

the problem's are with the display updating and mapping.

thanks.
 

Attachments

  • 00590c.pdf
    137.6 KB · Views: 585
I haven't actually constructed this, nor tried to extract the code from the PDF and simulate it, but I'll take a stab at it.

You say you are having problems with the display. The sheet you attached says that it is using common cathode 7-segment displays. Are you using CC's, which recieve the active high data on individual anodes, or are you erroneously using common anode displays which are expecting active low data on the cathodes?

Another thing is that they are using PNP transistors with the collector (diagonal without the arrow) grounded. Code lines 00091 through 00095 confirm that they want a PNP, because the single 0's they have bringing the base (straight line) low activates the connection to ground. I find their use of PNPs peculiar, as I have only used a PNP with the emitter (arrowed line) connected to supply voltage. The collector then powers anything connected to it whenever the base input drops below the emitter voltage. With NPN's, however, I connect the emitters to ground. The collector provides a sink to whatever is connected to it when the base voltage rises above the emitter. Those are the only two configurations I have ever used. When I look at their diagram with the PNPs emitter connected to the common cathode of the LEDs, I have to wonder what condition would cause the transistor to activate? I can only assume: When the base voltage drops below whatever random signal is momentarily present on the LEDs, it shorts the grounded collector "up" to the emitter, providing a sink for the display. I don't like that. It may be perfectly acceptable, or maybe they just had some PNPs laying around. I don't know. But if I was designing the circut, I would put NPN transistors in place, ground the emitters, connect the collectors to the common cathodes, and change lines 00091 to 00095 of the code to reflect that change:

Code:
DISP1 equ B’00000001’
DISP2 equ B’00000010’ ; Mapping of Active Display Selection (PORT_A)
DISP3 equ B’00000100’
DISP4 equ B’00001000’
DISPOFF equ H’00’

That would cause the 1's there to "turn on" the ground to the collector, and provide a sink to the 7-seg cathode.

Another thing you might want to double check is a decoupling capacitor. Some people say that you don't need them for some applications, and they're right. You can make simple circuits that work acceptably without any caps. Sometimes adding a capacitor somewhere on your board between the supply and ground will fix a problem. I found that out when a capacitor made my own homemade clock start working. 8) Sometime you may even need to put a capacitor right beside the PIC's own power and ground pins.

If these suggestions don't fix your problem, perhaps you could describe in more detail exactly what is happening?
 
HI

first of all the display lights up no problem the digits can be drived on by one i did a test code on them they are fine.

i am using a CA 7-segments .(look at the drive.gif) .oh and the IC between the PIC and the disply is a ULN2003 (7 NPN's)

the errors are

1. the display should startup at 12:00 it starts at 00:00

2. from R to L the first 3 digits count together MINUTS

3. the forth digit count 10's MINUTS

iam not worried for know about the function off the switches iam trying to get the display correct.

note: my display lines are b'00000001'
b'00000010'
b'00000100'
b'00001000' to drive a NPN

i tryed re assigne the digits to the disply postion in the CYCLE lines at the end fo the CODE, i got the MINUTS in the first digit (0) and the digit next to it count 10's but the 3rd and forth they folow the MINUTS insted fo HOURS.

thanks
 

Attachments

  • clock_557.gif
    clock_557.gif
    89.1 KB · Views: 1,701
  • drive.gif
    drive.gif
    4.7 KB · Views: 1,691
hi

just an update ................you are right i did not pay attention to the transistors they are PNP and now the clock works fine and the display
is fine .

and the maze is the display will not show the correct numbers if i use NPN transistors even if i change the disply BITS in the code.

isnt against electricty rules to use PNP on the CC of a disply or they are using this TRICK so the PNP leaks to the display not to sink!!!!!!!!!!!!!!!


NOW i have to find a diffrent way to drive my CA displys and make the code work for them.
 
hi did 'not hear from you

the code is working fine with the CC displays and PIC16C54 on the
proto_ board...BUT not with my big CA displays and 16F877 .

iam posting my code can you please take a look and kind direct me in the right way to fix it,

the big CA diplay's as its wired working fine i did some test codes and i can display scaned numbers on it with no problem.
 

Attachments

  • j_clock.txt
    12.7 KB · Views: 410
I didn't realize you were asking a question. You mentioned it was working fine, then you said you were going to set off to making it work with common anode displays. It you look at their connection diagram, you will see that B0 is connected to the decimal point, B1 to segment A, B2 to segment B, etc..., and you see the position of the segments in the picture. You did not change your equates for ZERO, ONE, TWO, etc. They are still the same as the ones given on the original program listing, starting with line 00068. These need to be changed.

Code:
   A
  ---
F| G |B
  ---               These are the 7 segment labels
E|   |C
  ---
   D

Here's how the numbers are encoded: If you want to make a zero display on a common cathode display, you need to source voltage to segments A, B, C, D, E, and F, while leaving segment G off and the decimal point off. So matching those segment letters with Port B outputs, that would be 0111 1110 which is 7E in hex. Notice the ZERO equ H'7E' ? That's what that's all about. For a digit one, you want B and C on, all others off. 0000 1100 = H'0C'.

Now, if we want to switch over to driving common anode displays, the way to turn on a particular segment is to output grounds. For the number three, you would want A, B, C, D, and G grounded. Give them zeros, and everything else ones. 0110 0001 = H'61'. Do the rest of your numbers like that.
 
thanks for replaying

i agree with you on the sigments change ...but that will work if the cathod

sigments conected directly to PORTD.

in my case if you look at DRIVE.GIF i have a ULN2003 driving the sigments.

witch mean i need a 1 at the inputs to have a (0) at the output thats why i left the sigments decoding the same way.

like i said i can display all the numbers fine if i send test code to the displays.

its just the clock code will not work!!!

this is a code for the PIC54 and iam using F877 dose the RAM file reasigment affect the code its start at 0x08 and i start it at 0x20 for the F877.
 
whoah.. lol what was that mess..that you call clock code..
maybe if you use the code tab in the post screen it will look better..
 
Do you have anything better...?

this code was written by MICROCHIP engineers 1997 it's called AN590.

it was for the PIC16C54 ,

i only changed it to work with PIC16F877 and i am having problems to make it work

and i only get a laugh from you

thanks
 
prosound90 said:
Do you have anything better...?

this code was written by MICROCHIP engineers 1997 it's called AN590.

it was for the PIC16C54 ,

i only changed it to work with PIC16F877 and i am having problems to make it work

and i only get a laugh from you

thanks
sorry , maybe it looks different on your pc but this is what i see...
Code:
;********************************************************** ;* J-CLOCK.ASM ;********************************************************** ;* ;* DEC 05 2004 ;* Assembled with MPASM V5.70.40 ;********************************************************** ;* SW2 = RA4 (no sw1) ;* SW3 = RA5 ;* TEMP_port = AN0 . AN2 . AN3 (not used for now) ;* T1 = RB0 ;* T2 = RB1 ;* T3 = RB2 ;* T4 = RB3 ;* RD0 = DP ;* RD1 = SIG A ;* RD2 = SIG B ;* RD3 = SIG C ;* RD4 = SIG D ;* RD5 = SIG E ;* RD6 = SIG F ;* RD7 = SIG G ;* ;********************************************************** list p=16F877 ; Include file, change directory if needed include C:\PROGRA~1\MPLAB\P16F877.inc ;************************** Header ************************* ;***** VARIABLE DEFINITIONS w_temp EQU 0x70 ; variable used for context saving status_temp EQU 0x71 ; variable used for context saving ; POINTER equ 0x00 TMR0 equ 0x01 ; ; REG. Bits CARRY equ 0 ; Carry Bit is Bit.0 of F3 C equ 0 DCARRY equ 1 DC equ 1 Z_bit equ 2 ; Bit 2 of F3 is Zero Bit Z equ 2 P_DOWN equ 3 PD equ 3 T_OUT equ 4 TO equ 4 ; ZERO equ H'7E' ONE equ H'0C' TWO equ H'B6' THREE equ H'9E' FOUR equ H'CC' FIVE equ H'DA' SIX equ H'FA' ; Mapping of segments for display (PORT_D) SEVEN equ H'0E' EIGHT equ H'FE' NINE equ H'CE' COLON equ H'01' T equ H'F0' BLANK equ H'00' ; MAXNTHS equ D'12' ; constants for timer variable count up MAXSECS equ D'196' ; variables roll over in HEX at time roll over, see variable MAXMINS equ D'196' ; explanation MAXHRS equ D'244' MINHRS equ D'243' ADJMIN equ D'9' ; number of nths that need to be subtracted each minute ADJHR equ D'34' ; nths added each hour for accurate time ADJDAY equ D'3' ; nths subtracted each 1/2 day rollover ; DISP1 equ B'00000001' DISP2 equ B'00000010' ; Mapping of Active Display Selection (PORT_b) DISP3 equ B'00000100' DISP4 equ B'00001000' DISPOFF equ H'00' SWITCH equ B'00110000' ; Activate RA0,2,3 for switch inputs ; ; Flag bit assignments SEC equ H'0' ; update time display values for sec, min, or hours MIN equ H'1' HRS equ H'2' CHG equ H'3' ; a change has occurred on a switch or to a potentially displayed value SW1 equ H'4' ; Flag bit assignments - switches that are on = 1 SW2 equ H'5' ; SW1 is Seconds-minutes, SW2-hours, SW3-mode SW3 equ H'6' SW_ON equ H'7' ; a switch has been pressed ; ; VARIABLES keys equ H'31' ; variable location - which keys are pressed? bit0/sw1... flags equ H'32' ; bit flags; 0-SEC, 1-MIN, 2-HRS, 3-CHG, 4-SW1, 5-SW2, 6-SW3 ; equ H'33' ; Not Used display equ H'34' ; variable location - which display to update digit1 equ H'35' ; Rightmost display value digit2 equ H'36' ; Second display from right digit3 equ H'37' ; Third " " " digit4 equ H'38' ; Fourth (and Leftmost) ; ; timer variables start at a number that allows rollover in sync with time rollover, ; i.e. seconds starts at decimal 195 so that sixty 1-second increments causes 0. sec_nth equ H'39' ; seconds, fractional place seconds equ H'3A' ; seconds minutes equ H'3B' ; minutes hours equ H'3C' ; hours var equ H'3E' ; variable for misc math computations count equ H'3D' ; loop counter variable count2 equ H'3F' ; 2nd loop counter for nested loops ; ;********************************************************************************
 
thanks for replaying

i did find the lines that i should change (the hard way)

and the display part is working fine now, iam going to work on remapping

the switches from PORTB to PORTA and change it from LOW to HI.

if i need more help i will post the code as .ASM in ZIP format.

thanks any way
 
williB said:
thats why i suggested using the CODE tab..
¿Que?

How are you seeing all that A) displayed in this message thread and B) without line feed/returns? When I look at this thread, I see his j_clock.txt as an attachment that you can download. When I click on the paperclip it downloads, and then opens in Notepad, in nice neat readable form. I'm not sure how you are experiencing the problem that you are.
:?
 
You can post your code like this ..
in the "post a Reply" screen just paste your code AFTER you click on the the code tab..

Code:
;
;********************************************************************
	LIST    P = 16C54, n = 66
;
;                      Clock
;*********************************************************************
;
;			PROGRAM DESCRIPTION
;
; This program runs on a PIC16C54.   
;
;                       Hardware Description
;
;  DISPLAYS
; Four 7 segment displays are multiplexed.  The segments are tied together, with
; the common cathode pins broken out separately.  The display appears as a clock
; with a center semicolon ( 88:88 ).  The segments are assigned to Port B, with the
; semicolon being RB0, and segments A through F assigned as RB1 to RB7 respectively.
;  The four common cathodes are attached to the four Port A pins through transistors.
; RA0 for LED0, RA1/LED1... through LED3.  The center semicolon is made from the decimals
; of LED 2 and 3.  LED display 2 is turned upside down to put its decimal into position,
; but it is wired with a corrected A-F assignment to compensate.  Both decimals 
; are tied together at RB0, but the display cathodes are still separate.
;
;  SWITCHES
; Because all twelve I/O pins are already used for the muxed displays, the four 
; switches must be switched in alternatingly through software.  The switches 
; lie across Port B pins, which wil be changed to inputs momentarily during read
; and changed back to outputs during display.
;
;
;
;       Program:          CLOCK54.ASM 
;       Revision Date:   
;                         1-16-97      Compatibility with MPASMWIN 1.40
;
;
;**************************   Header *************************
;
;
PIC54   equ     H'01FF'
PIC56	equ	H'03FF'
;
POINTER	equ	H'00'
RTCC    equ     H'01'
PC      equ     H'02'
STATUS  equ     H'03'       ; F3 Reg is STATUS Reg.
FSR     equ     H'04'
;
PORT_A  equ     H'05'	; 7 segment Display Common Cathodes
PORT_B  equ     H'06'       ; Center Colon and Muxed Display Segments (Switches when inputs)
;
                        ; STATUS REG. Bits
CARRY   equ     0       ; Carry Bit is Bit.0 of F3
C       equ     0
DCARRY  equ     1
DC      equ     1
Z_bit   equ     2       ; Bit 2 of F3 is Zero Bit
Z       equ     2
P_DOWN  equ     3
PD      equ     3
T_OUT   equ     4
TO      equ     4
PA0     equ     5       ;16C5X Status bits
PA1     equ     6       ;16C5X Status bits
PA2     equ     7       ;16C5X Status bits
;
ZERO	equ	H'7E'
ONE	equ	H'0C'
TWO	equ	H'B6'
THREE	equ	H'9E'
FOUR	equ	H'CC'
FIVE	equ	H'DA'
SIX	equ	H'FA'	; Mapping of segments for display (PORT_B)
SEVEN	equ	H'0E'
EIGHT	equ	H'FE'
NINE	equ	H'CE'
COLON	equ	H'01'
T	equ	H'F0'
BLANK	equ	H'00'
;
MAXNTHS	equ	D'12'	; constants for timer variable count up
MAXSECS	equ	D'196'	;  variables roll over in HEX at time roll over, see variable
MAXMINS	equ	D'196'	;  explanation
MAXHRS	equ	D'244'
MINHRS	equ	D'243'
ADJMIN	equ	D'9'	; number of nths that need to be subtracted each minute
ADJHR	equ	D'34'	; nths added each hour for accurate time
ADJDAY	equ	D'3'	; nths subtracted each 1/2 day rollover
;
DISP1	equ	B'11111110'
DISP2	equ	B'11111101'	; Mapping of Active Display Selection (PORT_A)
DISP3	equ	B'11111011'
DISP4	equ	B'11110111'
DISPOFF	equ	H'FF'
SWITCH	equ	B'00001110'	; Activate RB1-3 for switch inputs     
;
;  Flag bit assignments
SEC	equ	H'0'	; update time display values for sec, min, or hours
MIN	equ	H'1'
HRS	equ	H'2'
CHG	equ	H'3'	; a change has occurred on a switch or to a potentially displayed value				 
SW1	equ	H'4'	; Flag bit assignments - switches that are on = 1
SW2	equ	H'5'	;  SW1 is Seconds-minutes, SW2-hours, SW3-mode
SW3	equ	H'6'
SW_ON	equ	H'7'	; a switch has been pressed
;
;   VARIABLES
keys	equ	H'08'	; variable location - which keys are pressed? bit0/sw1... 
flags	equ     H'09'	; bit flags; 0-SEC, 1-MIN, 2-HRS, 3-CHG, 4-SW1, 5-SW2, 6-SW3
;	equ	H'0A'	; Not Used
display equ     H'0B'	; variable location - which display to update
digit1	equ	H'0C'	; Rightmost display value
digit2	equ	H'0D'	; Second display from right
digit3	equ	H'0E'	; Third    "       "    "
digit4	equ	H'0F'	; Fourth (and Leftmost)
;
;	timer variables start at a number that allows rollover in sync with time rollover,
;	 i.e. seconds starts at decimal 195 so that sixty 1-second increments causes 0.
sec_nth	equ	H'10'	; seconds, fractional place
seconds	equ	H'11'	; seconds
minutes	equ	H'12'   ; minutes
hours	equ	H'13'   ; hours
var	equ	H'14'	; variable for misc math computations
count	equ	H'15'	; loop counter variable
count2	equ	H'16'	; 2nd loop counter for nested loops

;
;********************************************************************************
;
;  Initialize Ports all outputs, blank display
;
START   movlw	H'03'   ; set option register, transition on clock,
        option		; Prescale RTCC, 1:16 
;
	movlw	0
	tris	PORT_A	; Set all port pins as outputs
	tris	PORT_B
	movlw	BLANK
	movwf	PORT_B	; Blank the display
	bcf	STATUS,PA1
	bcf	STATUS,PA0
;
;  initialize variables
	movlw	H'01'
	movwf	RTCC	; set RTCC above zero so initial wait period occurs
	movlw	H'FE'
	movwf	display	; initializes display selected to first display.
	movlw	BLANK	; put all displays to blank, no visible segments
	movwf	digit1
	movwf	digit2
	movwf	digit3
	movwf	digit4
	movlw	MAXNTHS	; set timer variables to initial values
	movwf	sec_nth
	movlw	MAXSECS
	movwf	seconds
	movlw	MAXMINS
	movwf	minutes
	movlw	H'FF'	; hours start at 12 which is max at FF
	movwf	hours
	movlw	H'00'
	movwf	flags
;
;?  call converts for minutes and hours to initialize display vsriables
;
MAIN 
;
;  wait for RTCC to roll-over
RTCC_FILL
	movf	RTCC,0
	btfss	STATUS,Z  ; note, RTCC is left free running to not lose clock cycles on writes
	goto	RTCC_FILL
;
	incfsz	sec_nth,1  ;  add 1 to nths, n X nths = 1 sec, n is based on prescaler
	goto	TIME_DONE
	movlw	MAXNTHS
	movwf	sec_nth  ; restore sec_nths variable for next round
;
CHECK_SW
	btfss	flags,SW_ON ; if no switches press, bypass this
	goto	SET_TIME
	btfsc	flags,SW1
	goto	SET_TIME    ; if seconds display is pressed, do not change time
	movlw	MAXSECS
	movwf	seconds	    ; reset seconds to zero when setting clock
	movlw	H'7F'
	movwf	sec_nth	    ; advance second timer 1/2 second to speed time setting
	btfss	flags,SW2
	goto	HOURSET	    ; minutes do not need changing, check hours
	movlw	H'AF'
	movwf	sec_nth	    ; advances timer faster when setting minutes
	incfsz	minutes,1
	goto	HOURSET
	movlw	MAXMINS
	movwf	minutes
;
HOURSET	btfsc	flags,SW2
	goto	CHECK_TIME ; not changing hours
	incfsz	hours,1
	goto	CHECK_TIME
	movlw	MAXHRS
	movwf	hours
	goto	CHECK_TIME ; since no timing is required, go to display changes
;
SET_TIME
	bsf	flags,SEC ; seconds, if displayed, should be updated
	bsf	flags,CHG ; a flag change was made.
	incfsz	seconds,1 ;  add 1 to seconds
	goto	TIME_DONE
	movlw	MAXSECS
	movwf	seconds   ; restore seconds variable for next round
;
	bsf	flags,MIN ; minutes, if displayed, should be updated
	bsf	flags,CHG
	movlw	ADJMIN
	subwf	sec_nth,1 ; subtraction needed adjustment for each minute
	incfsz	minutes,1  ; add 1 to minutes
	goto	TIME_DONE
	movlw	MAXMINS
	movwf	minutes	  ; restore minutes variable for next hour countdown
;
	bsf	flags,HRS
	bsf	flags,CHG
	movlw	ADJHR
	addwf	sec_nth,1 ; add needed adjustment for each hour
	incfsz	hours,1	  ; add 1 to hours
	goto	TIME_DONE
	movlw	MAXHRS
	movwf	hours	  ; restore hours variable for next round
	movlw	ADJDAY
	subwf	sec_nth,1 ; subtraction adjustment for each 1/2 day rollover
;
TIME_DONE
	btfss	flags,CHG	; if no switches or potentially dislayed numbers were
 	goto	CYCLE		;  changed, then skip updating display variables
;
;
CHECK_SECONDS
;  if seconds is button was pushed and not mode display seconds
	btfss	flags,SW1
	goto	CHECK_TIME
	movlw	H'00'
	movwf	digit2	; 3rd digit variable used to store temp hex value for hours display
	movwf	digit3
	movwf	digit4
	movlw	MAXSECS
	subwf	seconds,0
	movwf	digit1  ; 1st digit variable temporarily holds hex value for seconds display
	goto	SPLIT_HEX
;
CHECK_TIME
	movlw	H'00'
	movwf	digit4	  ; zero out tens places in case there is no tens increment
	movwf	digit2
	movlw	MINHRS
	subwf	hours,0
	movwf	digit3    ; 3rd digit variable temporarily holds hex value for hours
	movlw	MAXMINS
	subwf	minutes,0
	movwf	digit1	  ; 1st digit temporarily holds hex value for minutes
;
;
;
SPLIT_HEX	;  split into two hex display variables and write
;
	movlw	H'02'
	movwf	count	; loop to convert each number - seconds - or minutes and hours

;1st time through, FSR = digit1, 2nd time FSR = digit3
	movlw	digit1	; 
	movwf	FSR	; address of digit1 into File Select Register enables POINTER
	goto	LOOP	; this loop is used to modify the minutes/seconds place
;
LOOP2	movlw	digit3
	movwf	FSR	; this loop is used to modify the hours place
;
LOOP
	movlw	D'10'
	subwf	POINTER,1       ; find out how many tens in number,
	btfsc	STATUS,C        ; was a borrow needed?
	goto	INCREMENT_10S   ;  if not, add 1 to tens position
	addwf	POINTER,1       ;  if so, do not increment tens place, add ten back on to get 1s
	goto	NEXT_DIGIT
;
INCREMENT_10S
	incf	FSR,1	  ; bump address pointed to from 1s positoion to 10s
	incf	POINTER,1 ; add 1 to 10s position as determined by previous subtract
	decf	FSR,1	  ; put POINTER value back to 1s place for next subtraction
	goto    LOOP	  ; go back and keep subtracting until finished
;
NEXT_DIGIT
	decfsz	count,1
	goto	LOOP2
;
CONVERT_HEX_TO_DISPLAY  ; converts hex number in digit variables to decimal display code
	movlw	digit1	
	movwf	FSR	; put the address of the first digit into the FSR to enable POINTER
	movlw	H'04'
	movwf	count	; prepare count variable to loop for all four displays
NEXT_HEX
	movf	POINTER,0    ; get the hex value of the current digit variable
	call	RETURN_CODE  ; call for the hex to decimal display conversion
	movwf	POINTER	     ; put the returned display code back into the digit variable
	incf	FSR,1	     ; increment the pointer to the next digit variable address
	decfsz	count,1	     ; allow only count(4) times through loop
	goto	NEXT_HEX
;
FIX_DISPLAY
	movlw	ZERO
	subwf	digit4,0
	btfss	STATUS,Z
	goto	FIX_SEC
	movlw	BLANK
	movwf	digit4

FIX_SEC	btfss	flags,SW1
	goto	CLEAR_FLAGS
	movwf	digit3	
;
CLEAR_FLAGS
	movlw	H'F0'
	andwf	flags,1	     ; clear the lower 4 flag bits to show update status
;
CYCLE
;
	movlw	DISPOFF
	movwf	PORT_A	   ; Turn off LED Displays
	movlw	SWITCH
	tris	PORT_B	   ; Set some port B pins as switch inputs
	movlw	H'0F'
	andwf	flags,1	   ; reset switch flags to zero
	nop		   ; nop may not be needed, allows old outputs to bleed
	nop		   ;   off through 10k R before reading port pins
	nop
	movf	PORT_B,0
	movwf	var
	btfss	var,1
	goto	SWITCH2
	bsf	flags,CHG
	bsf	flags,SW1
	bsf	flags,SW_ON
SWITCH2	btfss	var,2
	goto	SWITCH3
	bsf	flags,CHG
	bsf	flags,SW2
	bsf	flags,SW_ON
SWITCH3	btfss	var,3
	goto	SETPORT
	bsf	flags,CHG
	bsf	flags,SW3
	bsf	flags,SW_ON
;
SETPORT	movlw	H'00'
	tris	PORT_B
	movlw	BLANK
	movwf	PORT_B
;
;   determine which display needs updating and cycle it on
	btfss	display,0  ; if 1st display, get 1st digit
	movf	digit4,0
	btfss	display,1  ; if 2nd display, get 2nd digit
	movf	digit3,0
	btfss	display,2  ; if 3rd display, get 3rd digit
	movf	digit2,0
	btfss	display,3  ; if 4th display, get 4th digit
	movf	digit1,0
	movwf	PORT_B	   ; put the number out to display
	btfsc	sec_nth,7
	bsf	PORT_B,0   ; sets colon decimal on %50 duty using highest bit
	movf	display,0  ; get display needing cycle on
	movwf	PORT_A	   ; enables proper display
	movwf	display    ; returns old w if not done, new w if resetting display
	rlf	display,1  ; rotate display "on" bit to next position
	bsf	display,0  ; assures a 1 on lowest position since rotated carry is zero
	btfss	display,4  ; check if last display was already updated
	bcf	display,0  ; if it was, set display back to 1st (bit 0 set)
;
;
;
        goto    MAIN
;
RETURN_CODE
;
	addwf	PC,1
	retlw	ZERO
	retlw	ONE
	retlw	TWO
	retlw	THREE
	retlw	FOUR
	retlw	FIVE
	retlw	SIX
	retlw	SEVEN
	retlw	EIGHT
	retlw	NINE
;
;
        org     PIC54
        goto    START
;
    END
 
williB said:
You can post your code like this ..
in the "post a Reply" screen just paste your code AFTER you click on the the code tab..

My previous reply seems to have been one of those that has disappeared, but the problem is with your PC, not the link to the code as he uploaded it. Your file associations are wrong, a .TXT file shouldn't open in IE (it's not designed for text files, and doesn't work - as you have found out). A file with an extension of .TXT should open in Notepad, or switch to Wordpad if it's too large (or some other text editor).

You need to repair your file type associations.
 
that particular file was the only one that did that .. ever..
every other one asks if i want to download..
 
Hey All...thanks for all the help and suggestions that I've read
here......I have a 4 digit 7 segment display built, tested and
working...I used CCS ....C code to test it.....Thanks for info
about AN590....I'm going to try converting that code to a pic
type 16F88 which is what I'm using....going to be using all
assembly language for this project( dual indoor/outdoor
thermometor) using two LM34CAZ's.....I dont think it will be to
difficult to convert from pic type 16C54 to type 16f88...or
will it??? Any hints greatly appreciated.....Tnx Art
 
ajc said:
Hey All...thanks for all the help and suggestions that I've read
here......I have a 4 digit 7 segment display built, tested and
working...I used CCS ....C code to test it.....Thanks for info
about AN590....I'm going to try converting that code to a pic
type 16F88 which is what I'm using....going to be using all
assembly language for this project( dual indoor/outdoor
thermometor) using two LM34CAZ's.....I dont think it will be to
difficult to convert from pic type 16C54 to type 16f88...or
will it??? Any hints greatly appreciated.....Tnx Art

No, it's pretty simple - but watch out for the GPR start address and reset vector.
 
Tnx Nigel for the help...appreciate it....going to convert the code
and simulate it using MPLABSIM....tnx Art
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top