;*****This program is used to drive the LED digital tube display, and display the numbers 1, 2, 3, 4, 5, 6, 7, 8 on the 8 LED digital tubes in sequence*******
;****http://www.51hei.com The classic program of the microcontroller learning network has been tested. If the common cathode and common anode of the LED digital tube are different, please modify the code value conversion table part
LIST P=18F458
INCLUDE "P18F458.INC"
;The register used
XIANR EQU 0X20
ORG 0X00
GOTO MAIN
ORG 0X30
;****************The following is the code value conversion table********************
CONVERT ADDWF PCL, 1
RETLW 0XC0 ;0, the display segment code is related to the specific hardware connection
RETLW 0XF9 ;1
RETLW 0XA4 ;2
RETLW 0XB0 ;3
RETLW 0X99 ;4
RETLW 0X92 ;5
RETLW 0X82 ;6
RETLW 0XD8 ;7
RETLW 0X80 ;8
RETLW 0X90 ;9
RETLW 0X88 ;A
RETLW 0X83 ;B
RETLW 0XC6 ;C
RETLW 0XA1 ;D
RETLW 0X86 ;E
RETLW 0X8E ;F
RETLW 0X7F ;"."
RETLW 0XBF ;"-"
RETLW 0X89 ;H
RETLW 0XFF ;DARK
RETURN
;**************Initialization subroutine********************
INITIAL
BCF TRISA,5 ;Set RA5 to output mode to output latch signal
BCF TRISC,5
BCF TRISC,3 ;Set SCK and SDO to output mode
BCF INTCON,GIE ;Turn off all interrupts
MOVLW 0XC0
MOVWF SSPSTAT ;Set SSPSTAT register
MOVLW 0X30
MOVWF SSPCON1 ;Set the SPI control mode, allow SSP mode, and
send data along the falling edge of the clock, which
corresponds to the characteristic of "74HC595 when its SCLK jumps from low to high level, the serial input data (DI) is moved into the register"
MOVLW 0X11 ;Assign initial values to the display value register, each value occupies two bytes,
MOVWF XIANR ;Start displaying from 8
RETURN ;Return
; ******************LED digital tube display subroutine **********************
;SPI transmission display submodule
DISPLAY
TRANSMIT CLRF PORTA ;LACK sends low level to prepare for latching
MOVWF SSPBUF ;Start sending
WAIT
BTFSS PIR1, SSPIF
GOTO WAIT ;Wait for the end of sending
BCF PIR1, SSPIF ;Clear interrupt flag
NOP
BSF PORTA, 5 ;Finally, give a latch signal to represent the completion of a display task
RETURN
;********************The main program of the pic microcontroller driving LED display program starts *****************
MAIN NOP
CALL INITIAL ;Call system initialization subroutine
LOOP MOVF XIANR, W
CALL CONVERT ;Find out the display segment code value of XIANR
CALL DISPLAY
DECF XIANR
DECF XIANR ;Decrease the display value by 2, because it is stored by word and read by byte
MOVF XIANR, W
SUBLW 0X01
BTFSS STATUS, Z
GOTO LOOP ;If the displayed number is sent, exit the display
HERE GOTO HERE
END
This program is completed. For the C language version of this program, please open http://www.51hei.com/mcu/558.html
Previous article:PIC microcontroller keyboard scanning assembly program
Next article:PIC18F458 single-chip microcomputer sleep state working mode and activation
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Ended | [Microchip Embedded Security Solutions | Security Resilience of Platform Firmware]
- FAQ: How to choose a suitable automotive MOSFET
- Sources of Power Consumption in SRAM
- 【Android development learning path】— by Bingqi23
- MSP430 MCU printf function transplantation
- Keyence vision camera communicates with Siemens 1500 PLC to achieve grasping correction with the robot
- LSM6DSO(X) sensor driver key code analysis: read_data_polling routine (Part 2)
- Xunwei STM32MP157 development board Linux + MCU learning materials and tutorials summary (manual + video)
- Microchip FAQ | TA100-VAO secure boot and message authentication for CAN FD in ADAS and IVI systems
- C2000 Piccolo MCU F28027F LaunchPad Development Kit