M. Amer Iqbal Qureshi


SHOut SER,SRCLK, lsbfirst



tải về 3.06 Mb.
Chế độ xem pdf
trang128/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)

SHOut SER,SRCLK,
lsbfirst
,[%00000000,%00000000,%00000000,%00000000] 
' send data 
Device=
18f452 
XTAL
=20 
ALL_DIGITAL
=true 
Output 
PORTB 
Input 
PORTA 
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 
High SRClr
' Turn off the serial register clear 
PulsOut Rowrst,2
' give a pulse on row reset pin, to select row 0 
SHOut SER,SRCLK,
lsbfirst
,[%11111110,%11111111,%11111111,%11111111] 
' send data 
on serial pin
PulsOut Latch,4 
End 
Fig. 6 Single LED is ON 


Teach Yourself PIC Microcontrollers | www.electronicspk.com | 141 
on serial pin
Now lets send some pattern, to show this 
effect.
SHOut SER,SRCLK,
lsbfirst
,[%
11111110,%10101010,%11001100,%
00011100] 
Notice the data, being sent, and the 
appearance of ON LEDs in Fig. 8. this 
clearly shows that the first byte sent, goes 
to extreme right, and last byte sent goes to extreme left. 
If we want to reverse the pattern , we can send Most significant bit first. 
Blinking an LED 
In order to make an LED Blink, you have to turn the corresponding column On, and OFF repeatedly after a 
set interval. 

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