;**********************************************************************
;* ********************Programme pricnipal********************
;**********************************************************************
Wait
movf TMR0,f ;set Z in STATUS if TMR0 = 0
btfss STATUS,Z ;bit test the Z bit, skip if set (= Zero)
goto Wait ;not zero yet so keep checking
decfsz Delay,f ;subtract 1 from Delay and see if zero
goto Wait ;not reached zero yet so keep checking
;'Delay' has reached zero so ~1 second has elapsed
movlw D'15' ;reload 'Delay' again
movwf Delay ; code to read the ADC comes next
;**********************************************************************
;* ********************Programme pricnipal********************
;**********************************************************************
Wait
movf TMR0,f ;set Z in STATUS if TMR0 = 0
btfss STATUS,Z ;bit test the Z bit, skip if set (= Zero)
goto Wait ;not zero yet so keep checking
;reload 'Delay' again
movwf Delay
; code to read the ADC comes nextdecfsz Delay,f ;subtract 1 from Delay and see if zero
goto Wait ;not reached zero yet so keep checking
;'Delay' has reached zero so ~1 second has elapsed
movlw D'15'
;**********************************************************************
;* ********************Programme pricnipal********************
;**********************************************************************
Wait
movf TMR0,f ;set Z in STATUS if TMR0 = 0
btfss STATUS,Z ;bit test the Z bit, skip if set (= Zero)
goto Wait ;not zero yet so keep checking
decfsz Delay,f ;subtract 1 from Delay and see if zero
goto Wait ;not reached zero yet so keep checking
;'Delay' has reached zero so ~1 second has elapsed
movlw D'15' ;reload 'Delay' again
movwf Delay
; code to read the ADC comes next
;**********************************************************************
;* ********************Variable declare ********************
;**********************************************************************
D1 EQU 0X20
D2 EQU 0X21
D3 EQU 0X22
D4 EQU 0X23
D5 EQU 0X24
D6 EQU 0X25
list p=10F220 ; list directive to define processor
#include <p10F220.inc> ; processor specific variable definitions
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS
cblock 0x09
Delay ;variable for the delay ,to make delays
Counter ;variable to count how many measurements
LCD_data ;hold the data to be sent to the LCD
Counter_data ; hold the counter for the bits as they are sent to the LCD
endc
;**********************************************************************
ORG 0x000 ; coding begins here
movwf OSCCAL ; update register with factory cal value
start
clrf LCD_data
clrf Counter_data
clrf Counter
clrf Delay
; remaining code goes here
Wait
movlw .15 ;reload 'Delay' again
movwf Delay
movlw 1 ;give TMR0 a start value
movwf TMR0
Wait1
movf TMR0,f ;set Z in STATUS if TMR0 = 0
btfss STATUS,Z ;bit test the Z bit, skip if set (= Zero)
goto Wait1 ;not zero yet so keep checking
decfsz Delay,f ;subtract 1 from Delay and see if zero
goto Wait1 ;not reached zero yet so keep checking
return
; read the voltage on the analog input pin, return result in W
ReadADC
bsf ADCON0,GO_NOT_DONE ;start measuring the voltage
ADC_Wait
btfsc ADCON0,GO_NOT_DONE ;skip next instruction if GO/-DONE is zero
goto ADC_Wait ;not finished yet!
movf ADRES,W ;copy the result to W
return
list p=10F220 ; list directive to define processor
#include <p10F220.inc> ; processor specific variable definitions
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ
;***************************************************************************
; *******************microcontroller initialization***************************************
;***************************************************************************
movlw b'00001001' ;sets GP1 and GP2 as Outputs
TRIS GPIO
movlw 0x41
movwf ADCON0
movlw 0xC7
option
;****************************************************************************
;***** VARIABLE DEFINITIONS**************************************************
;****************************************************************************
cblock 0x09
Delay ;variable for the delay ,to make delays
Counter ;variable to count how many measurements
LCD_data ;hold the data to be sent to the LCD
Counter_data ; hold the counter for the bits as they are sent to the LCD
endc
;**********************************************************************
;******************* coding begins*************************************
;**********************************************************************
ORG 0x000 ; coding begins here
movwf OSCCAL ; update register with factory cal value
start
clrf LCD_data
clrf Counter_data
clrf Counter
clrf Delay
;***********************************************************************
; remaining code goes here
;***********************************************************************
Wait
movlw .15 ;reload 'Delay' again
movwf Delay
movlw 1 ;give TMR0 a start value
movwf TMR0
Wait1
movf TMR0,f ;set Z in STATUS if TMR0 = 0
btfss STATUS,Z ;bit test the Z bit, skip if set (= Zero)
goto Wait1 ;not zero yet so keep checking
decfsz Delay,f ;subtract 1 from Delay and see if zero
goto Wait1 ;not reached zero yet so keep checking
return
;********************************************************************
; read the voltage on the analog input pin, return result in W
;********************************************************************
ReadADC
bsf ADCON0,GO_NOT_DONE ;start measuring the voltage
ADC_Wait
btfsc ADCON0,GO_NOT_DONE ;skip next instruction if GO/-DONE is zero
goto ADC_Wait ;not finished yet!
movf ADRES,W ;copy the result to W
return
;***** VARIABLE DEFINITIONS
cblock 0x10
Delay ;variable for the delay ,to make delays
Counter ;count the number of measurements
Total ;accumulation of ADC measurements
Average ;average value of the measurements
Temporary ;use for holding partial results in calculations
LCD_data ;hold the data to be sent to the LCD
Counter_data ;hold the counter for the bits as they are sent to the LCD
endc
;**********************************************************************
ORG 0x000 ; coding begins here
movwf OSCCAL ; update register with factory cal value
start
clrf LCD_data
clrf Counter_data
clrf Counter
clrf Delay
movlw b'00001001' ;sets GP1 and GP2 as Outputs
TRIS GPIO
movlw 0x41
movwf ADCON0
movlw 0xC7
option
MainLoop
movlw 4
movwf Counter
clrf Total
SumLoop
call Wait ;one second delay
call ReadADC ;take a measurement
movwf Temporary ;store the result
bcf STATUS,C ;must not shift carry bit into result
rrf Temporary,f ;divide result by 2
bcf STATUS,C ;must not shift carry bit into result
rrf Temporary,w ;divide by 2 with result in W
addwf Total ;add the result to the average
decfsz Counter,f ;see if 4 measurements have been averaged
goto SumLoop ;no - so repeat until all 4 taken
;Total = the sum of 4 readings taken at 1 second intervals
call LCDUpdate ;update the display
goto MainLoop
; remaining code goes here
Wait
movlw .15 ;reload 'Delay' again
movwf Delay
movlw 1 ;give TMR0 a start value
movwf TMR0
Wait1
movf TMR0,w ;set Z in STATUS if TMR0 = 0
btfss STATUS,Z ;bit test the Z bit, skip if set (= Zero)
goto Wait1 ;not zero yet so keep checking
Wait2
movf TMR0,w ;set Z in STATUS if TMR0 = 0
btfsc STATUS,Z ;wait for TMR0 to be NOT zero
goto Wait2
decfsz Delay,f ;subtract 1 from Delay and see if zero
goto Wait1 ;not reached zero yet so keep checking
return
; read the voltage on the analog input pin, return result in W
ReadADC
bsf ADCON0,GO_NOT_DONE ;start measuring the voltage
ADC_Wait
btfsc ADCON0,GO_NOT_DONE ;skip next instruction if GO/-DONE is zero
goto ADC_Wait ;not finished yet!
movf ADRES,W ;copy the result to W
return
; show the scaled result on the LCD
LCDUpdate
END ; directive 'end of program'
; LCD TRIS
Ban1 ;lcd RW leg is grounded, so we'll only write data to the lcd, and never read.
movlw b'11000000'
movwf tris_lcd ;all output ports
LCD_int
;use both lines of the display
movlw b'00000010' ;mode 4 bits
movwf port_lcd
call e_pulse
movlw b'00000010' ;mode 4 bits
movwf port_lcd
call e_pulse
;allow display and hide the cursor
movlw b'00001000' ;mode 4 bits
movwf port_lcd
call e_pulse
call busy
;Entry Mode Set
movlw b'00000000'
movwf port_lcd
call e_pulse
movlw b'00000110'
movwf port_lcd
call e_pulse
call busy
;---------------------------------------------------------------------------
; 50 us
;---------------------------------------------------------------------------
busy ; 50us
movlw 6
movwf temp_busy
attd_boucle
nop
nop
nop
decfsz temp_busy,F
goto attd_boucle
return
His is what I try to do for the LCD is it correct? and I do not understand the difference between LCD and LCD-SPI, How to code a LCD-SPI?
Code:; LCD TRIS Ban1 ;lcd RW leg is grounded, so we'll only write data to the lcd, and never read. movlw b'11000000' movwf tris_lcd ;all output ports LCD_int ;use both lines of the display movlw b'00000010' ;mode 4 bits movwf port_lcd call e_pulse movlw b'00000010' ;mode 4 bits movwf port_lcd call e_pulse ;allow display and hide the cursor movlw b'00001000' ;mode 4 bits movwf port_lcd call e_pulse call busy ;Entry Mode Set movlw b'00000000' movwf port_lcd call e_pulse movlw b'00000110' movwf port_lcd call e_pulse call busy ;--------------------------------------------------------------------------- ; 50 us ;--------------------------------------------------------------------------- busy ; 50us movlw 6 movwf temp_busy attd_boucle nop nop nop decfsz temp_busy,F goto attd_boucle return
His is what I try to do for the LCD is it correct? and I do not understand the difference between LCD and LCD-SPI, How to code a LCD-SPI?
In your project you are using only 2 wires to connect to LCD.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?