Файл: Microcontroller Programming. Thi Micro Chip PIC (Julio Sanchez, 2007).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 14.06.2025
Просмотров: 8581
Скачиваний: 0
336 |
Chapter 13 |
|
bcf |
PORTA,RS_line |
; RS line low, set up for |
; control |
||
call |
delay_5 |
; Busy? |
; Set to second display line |
||
movlw |
LCD_2 |
; Address with high-bit set |
call |
send8 |
|
; Set RS line for data |
||
bsf |
PORTA,RS_line |
; RS = 1 for data |
call |
delay_5 |
; Busy? |
return |
||
;===============================
;first text string procedure ;=============================== storeMSU:
;Procedure to store in PIC RAM buffer the message
;contained in the code area labeled msg1
;ON ENTRY:
;variable pic_ad holds address of text buffer
;in PIC RAM
;w register hold offset into storage area
;msg1 is routine that returns the string characters
;andiy a zero terminator
;index is local variable that hold offset into
;text table. This variable is also used for
;temporary storage of offset into buffer
;ON EXIT:
;Text message stored in buffer
;
;Store offset into text buffer (passed in the w register)
;in temporary variable
movwf |
index |
; Store w in index |
; Store base address of text buffer in FSR |
||
movf |
pic_ad,w ; first display RAM address to W |
|
addwf |
index,w |
; Add offset to address |
movwf |
FSR |
; W to FSR |
; Initialize index for text string access |
||
movlw |
0 |
; Start at 0 |
movwf |
index |
; Store index in variable |
; w still = 0 |
||
get_msg_char: |
||
call |
msg1 |
; Get character from table |
; Test for zero terminator |
||
andlw |
0x0ff |
|
btfsc |
STATUS,Z ; Test zero flag |
|
goto |
endstr1 |
; End of string |
;ASSERT: valid string character in w
;store character in text buffer (by FSR)
338 |
Chapter 13 |
|
; Restore table character counter from variable |
||
movf |
index,w |
; Get value into w |
addlw |
1 |
; Bump to next character |
movwf |
index |
; Store table index in |
; variable |
||
goto |
get_msg_char2 |
; Continue |
endstr2: |
||
return |
||
; Routine for returning message stored in program area msg2:
addwf |
PCL,f |
; Access table |
retlw |
‘S’ |
|
retlw |
‘t’ |
|
retlw |
‘a’ |
|
retlw |
‘t’ |
|
retlw |
‘e’ |
|
retlw |
‘,’ |
|
retlw |
0x20 |
|
retlw |
‘M’ |
|
retlw |
‘a’ |
|
retlw |
‘n’ |
|
retlw |
‘k’ |
|
retlw |
‘a’ |
|
retlw |
‘t’ |
|
retlw |
‘o’ |
|
retlw |
0 |
|
end |