Page 1 of 1

How to make PIC18 Voltmeter using 7-segment LED Display

PostPosted: Sun Dec 08, 2019 10:33 am
by vicky99
I have coded to perform ACD with interrupt. Now i need to transfer the data to two 7-Segment LED display. I am connecting my LED pins to Port C and Port D. How do I program to transfer the recieved byte from ADRESL and ADRESH to LED display?
My code for ADC with interrupt is given below:
LIST P=PIC18F458
#include P18F458.INC
ORG 0000H
GOTO MAIN
ORG 0008H
BTFSS PIR1, ADIF
RETFIE
GOTO AD_ISR
ORG 00100H
MAIN CLRF TRISC
CLRF TRISD
BSF TRISA, 0
MOVLW 81H
MOVWF ADCON0
MOVLW 0CEH
MOVWF ADCON1
BCF PIR1, ADIF
BSF PIE1, ADIE
BSF INTCON, PEIE
BSF INTCON, GIE
OVER CALL DELAY
BSF ADCON0, GO
BRA OVER

AD_ISR
ORG 200H
MOVFF ADRESL, PORTC
MOVFF ADRESL, PORTD

BCF PIR1, ADIF
RETFIE
END

Kindly help me how to code to send the HByte and LByte data to 7- segment led display

Re: How to make PIC18 Voltmeter using 7-segment LED Display

PostPosted: Sun Dec 08, 2019 1:38 pm
by Roche
There are a few things to think about:

What format do you want to display in? Hexadecimal, decimal or something else?

Given that the resolution of the A to D is 10 bit, do you want to display the most or least significant bits? Given that in hexadecimal the maximum would be FF or in decimal 99...

The mapping between individual bits of the port and segments of the display depends on your hardware - you need to make a table of values that correspond to displayed digits. Then you could possibly use a lookup table to generate the display...

Re: How to make PIC18 Voltmeter using 7-segment LED Display

PostPosted: Sun Dec 08, 2019 10:43 pm
by ric
The same question is getting a fair bit of help at https://www.microchip.com/forums/m1120364.aspx