M. Amer Iqbal Qureshi



tải về 3.06 Mb.
Chế độ xem pdf
trang130/132
Chuyển đổi dữ liệu09.12.2022
Kích3.06 Mb.
#53945
1   ...   124   125   126   127   128   129   130   131   132
Amer Iqbal - Teach Yourself PIC Microcontrollers for Absolute Beginners-Microtronics Pakistan (2001)

Device=
18F452 
XTAL
=20 
ALL_DIGITAL
=true 
Output 
PORTB 
Input 
PORTE 
Symbol SER = 
PORTB
.0
' Serial data Pin 
Symbol SRCLK = 
PORTB
.1
' Serial data Clock Pin 
Symbol SRClr = 
PORTB
.2
' Serial data Clear 
Symbol Latch = 
PORTB
.3
' Columns, Latch 
Symbol RowClk = 
PORTB
.4 
' Row clock, to select new row 
Symbol Rowrst = 
PORTB
.5 
' Row reset, selects row 0 
Symbol SW1=
PORTE
.0 
Symbol SW2=
PORTE
.1 
High SRClr
' Turn off the serial register clear 
 
Dim s[32] As Byte 
Dim As Byte 
Dim As Byte 
Dim As Byte 
Dim As Byte 
Dim z[4] As Byte 
z[0]=0 
z[1]=1 
z[2]=1 
z[3]=0 
' initialize the array by writing 0 to all bits
For i=0 To 31 
s[i]=$FF 
Next 
For c = 0 To 
For i= 0 To 
b=(i*4) + c 


Teach Yourself PIC Microcontrollers | www.electronicspk.com | 143 
As we have defined the character map as 8 bits wide, whereas our actual character is using only 5 bits. 
There are 3 bits empty, 1 on right and 2 on left side of each character. If we want to ignore the highest 2 
bits, and we just want to send the lowest 6 bits to the display, for each character, we can do that by just 
mentioning the number of bits in Shout command. Change the Shout command like this: 
SHOut SER,SRCLK,
lsbfirst
,[s[n]\6, s[n +1]\6, s[n+2]\6, s[n+3]\6] 
Notice the \6 with every byte sent. If this is not mentioned then default, 8 bits is assumed. You can send any 
number of bits you want. The result of this would be: 
You can make these letters 
scroll, make special effects, and 
animations, however we leave 
this to you, so that you learn 
while explore. 
 
s[b]=ERead (z[c]*8)+i 

tải về 3.06 Mb.

Chia sẻ với bạn bè của bạn:
1   ...   124   125   126   127   128   129   130   131   132




Cơ sở dữ liệu được bảo vệ bởi bản quyền ©hocday.com 2024
được sử dụng cho việc quản lý

    Quê hương