M. Amer Iqbal Qureshi



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

    Điều hướng trang này:
  • Symbol
Device=
18F452 
XTAL
=20 
ALL_DIGITAL
=true 
Output 
PORTB 
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 
 
Remember, if no data is clocked to shift registers, they will be in state of 0 on their outputs, and since 0 on a 
column selects it, so all columns will be selected. A logical 1 on a column will turn the column off, and a 0 
will turn the column ON. 
The PulsOut  command gives a small high pulse on the specified pin. The 
number indicates duration of pulse. 2 in this case will give a 4us pulse. 
However thgis timing is not crucial for the function of display. 
SHOut  is the command that transmits the contents of a byte, or word, as 
a stream of bits on a single pin. The arguments are the pin, on which data 
is to be transmitted, the Clock pin to be used to clock the shift registers, 
lsbfirst  is a reserved word, indicating least significant bit first. So it will 
transmit, the bit 0 of data first and bit 7 last. The numbers in square 
brackets are the data to be sent. These are 4 bytes of data the first byte is sent first, from left side, the next 
three bytes push the first sent byte successively to right, so at the end of all 4 bytes the first Byte has been 
sent to the right most 8 columns. You can play with these four bytes to make various leds, ON. You must 
have noticed that the column corresponding to 0 is turned on. So to turn the entire row ON, just send this 
data: 

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