[dcpu16] SE1
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- ;**********************************************************
- ;* SE1.asm
- ;**********************************************************
- ;* Microchip Technology Incorporated
- ;* 17 March 2003
- ;* Assembled with MPASM V3.20 and MPLINK v3.20
- ;**********************************************************
- ;* This assembly language program that reads the analogue voltage generated by
- ;* potentiometer R16 on the Minimal Board, converts it to a 4-bit number, and
- ;* writes that number to the PortB LEDs to give a light bar bit pattern as
- ;* the potentiometer is turned. The light bar is to have 4 states,
- ;* corresponding to the numbers 0, 1, 3 and 7.
- ;*
- ;* By Vishant Prasad (470416309)
- ;**********************************************************
- #include "p18cxxx.inc" ;wrapper for all PIC18 symbols
- ; if building for PIC18F452
- #include "ConfigRegsPIC18f452.inc" ;set Configuration Registers
- ;Start at reset adress - declares code section 'RST'
- RST code 0x0000
- goto Setup
- ;Declares code section
- code 0x0030
- Setup:
- clrf PORTD ;Clear PORTD
- clrf TRISD ;Set PORTD to Output
- movlw B'01000001' ;Enable the A/D - Timing: FOSC/8 (Internal Clock)
- movwf ADCON0 ;Enable the A/D Control Register
- movlw B'00001110' ;Analog Channel - take VDD & VSS as references
- movwf ADCON1
- movlw B'11000111' ;Timer 0 ON - 1:256 prescaler
- movwf T0CON
- Main:
- btfss INTCON, TMR0IF ;Detect Timer 0
- goto Main
- bcf INTCON, TMR0IF
- bsf ADCON0, GO ;Trigger the A/D Conversion
- goto ADConversion
- ClearBit:
- btfsc ADRESH, 6 ;Check if bit is clear through comparison
- goto LED_I1 ;Set LED to 01
- movlw B'00000000' ;Set LED to 00 otherwise
- movwf PORTD ;LED values set from WREG
- goto Main
- LED_I1:
- movlw B'00000001' ;Set LED to 01
- movwf PORTD ;LED values set from WREG to PORTB
- goto Main
- SetBit:
- btfsc ADRESH, 6 ;Check if bit is clear through comparison
- goto LED_I2 ;Set LED to 11
- movlw B'00000011' ;Set LED to 10 otherwise
- movwf PORTD ;LED values set from WREG
- goto Main
- LED_I2:
- movlw B'00000111' ;Set LED to 11
- movwf PORTD ;LED values set from WREG
- goto Main
- ADConversion:
- btfss PIR1, ADIF ;Wait for flag bit from A/D conversion
- goto ADConversion
- swapf ADRESH, W ;Swap A/D conversion result
- andlw 0x0f ;Remove last 4 bits
- btfsc ADRESH, 7 ;Check if bit is clear through comparison
- goto SetBit ;Set bit if clear
- goto ClearBit ;Otherwise clear bit
- end
Editor
You can edit this paste and save as new:
File Description
- SE1
- Paste Code
- 26 Sep-2021
- 2.81 Kb
You can Share it:
Latest Code Pastes