Useful Macros

PIC12 and PIC16 ;*********************************************** ;********** USEFUL DEFINES AND MACROS ********** ;*********************************************** #define skip_if_c btfss status,c #define skip_if_nc btfsc status,c #define skip_if_z btfss status,z #define skip_if_nz btfsc status,z ;compare file to w, skip if f=w cpfseq_macro macro reg xorwf reg,w skip_if_z endm ; ;compare file to w, skip if f<>w cpfsneq_macro macro reg xorwf reg,w skip_if_nz […]

Read More

High Low

Getting High and Low Byte Of A 16 Bit Value movlw high 8332 movwf spbrgh movlw low 8332 movwf spbrg

Read More

Debounce Switches

Simple Debounce Only ;debounce the switches movf sw_inputs_0,w andwf sw_inputs_0_last,w movwf switches_debounced_0 movf sw_inputs_0,w movwf sw_inputs_0_last Detect New Keypresses Too ;—– DEBOUNCED SWITCHES —– #define SW_LCD_BRIGHTNESS_UP_PRESSED b0_switches_debounced_0,0 #define SW_LCD_BRIGHTNESS_DOWN_PRESSED b0_switches_debounced_0,1 ;—– NEW KEYPRESSES —– #define SW_LCD_BRIGHTNESS_UP_NEW b0_switches_new_0,0 #define SW_LCD_BRIGHTNESS_DOWN_NEW b0_switches_new_0,1 ;*********************************** ;*********************************** ;********** READ SWITCHES ********** ;*********************************** ;*********************************** read_switches clrf b0_switches_new_0 btfss b0_do_sw_read ;Set by […]

Read More