LDmicro0.1 MICRO=Microchip PIC16F877 40-PDIP CYCLE=1000 us at Timer1, YPlcCycleDuty:0, ConfigurationWord(s):0x3F62 CRYSTAL=20000000 Hz BAUD=2400 Hz, RATE=0 Hz, SPEED=0 Hz COMPILED=Z:\LDmicro_Common\Volmeter_1023\2x 4digit_voltmeter_CC-display.hex IO LIST An1 at 2 0 0 An2 at 3 0 0 END PROGRAM RUNG COMMENT -- 2x 4digit voltmeter(0..1023)x2 MGP Aug2019 END RUNG COMMENT MORE INFO https://github.com/LDmicro/LDmicro/wiki/X-segment-LED-display,-font-example END RUNG COMMENT -- slowdown for LSB readout 10times/sec END RUNG TCY Tslowdown 50000 0 OSR PARALLEL READ_ADC An1 0 READ_ADC An2 0 END END RUNG COMMENT -- digit counter END RUNG OSC CTC Cdigit 7 0 / END RUNG COMMENT -- digit0..3 = analog1 display1 END RUNG EQU Cdigit 0 OSR MOVE value An1 END RUNG COMMENT -- digit3...7 = analog2 display2 END RUNG EQU Cdigit 4 OSR MOVE value An2 END RUNG COMMENT --Calculate digits END RUNG PARALLEL DIV digit3 value 1000 MUL digit3x digit3 1000 SUB val value digit3x DIV digit2 val 100 MUL digit2x digit2 100 SUB valp val digit2x DIV digit1 valp 10 MUL digit1x digit1 10 SUB digit0 valp digit1x END END RUNG COMMENT -- Display END RUNG COMMENT -- store 2 analog signals (0..1023) into 2x 4digits MSB.....LSB MSB.....LSB\r\n------------------------------------------------ Cdigit=7...............Cdigit=0 END RUNG COMMENT ---PORTC= digitselect------------------------------ RC7....RC4 RC3.....RC0 \r\n---PORTB= segmentoutput ___RB7...........RB0 = dp g f e d c b a END RUNG COMMENT -- translate DECIMAL into 7segment info and select Cdigit=cathode(binary info) in portC END RUNG EQU Cdigit 0 7SEGMENTS segm digit0 C MOVE cathode 1 END RUNG EQU Cdigit 1 7SEGMENTS segm digit1 C MOVE cathode 2 END RUNG EQU Cdigit 2 7SEGMENTS segm digit2 C MOVE cathode 4 END RUNG EQU Cdigit 3 7SEGMENTS segm digit3 C MOVE cathode 8 END RUNG EQU Cdigit 4 7SEGMENTS segm digit0 C MOVE cathode 16 END RUNG EQU Cdigit 5 7SEGMENTS segm digit1 C MOVE cathode 32 END RUNG EQU Cdigit 6 7SEGMENTS segm digit2 C MOVE cathode 64 END RUNG EQU Cdigit 7 7SEGMENTS segm digit3 C MOVE cathode 128 END RUNG COMMENT -- PORTS B and C output END RUNG OSR PARALLEL MOVE #TRISB 0x00 MOVE #TRISC 0x00 END END RUNG COMMENT -- PORTB=segments and PORTC= digits END RUNG MOVE #PORTB segm END RUNG MOVE #PORTC cathode END