- sau khi xuat het cac byte thi xuat ra mot xung clkOUT ChiSo la bien toan cuc dc khoi tao do chuong trinh chinh
neu ChiSo bang 0, tuc la hang dau tien dc xuat, khi ay xuat ra DongBo = 1 neu ChiSo khac 0 thi xuat ra mot ra DongBo = 0
sau khi xuat het so byte kiem tra neu ChiSo = 63 thi dua tro ve 0 cong P1 xuat ra song song DuLieu
cac chan 21, 22, 23 (p20, p21, p22) dieu khien clkIN, clkOUT, DongBo mang char dc khai bao o ngoai
*/
#include <reg51.h>
//cac chan tin hieu dieu khien
sfr DuLieu = 0x90; //chan 1,2,3,4,5,6,7,8 cong P1 cua 8951 duong dl song song noi den dau vao bo dem ghi dich
sbit clkIN = 0xA0; //chan 21 8951 tao xung dich vao bo dem ghi dich sbit clkOUT = 0xA1; //chan 22 8951 tao xung xuat ra dong thoi cua bo dem
sbit DongBo = 0xA2; //chan 23 8951 tao xung dong bo hang dau tien, chan nay noi toi dau vao bo ghi dich quet hang
sfr ByteThapDinhThoi0 = 0x8A; sfr ByteCaoDinhThoi0 = 0x8C; sbit BatDinhThoi0 = 0x8C; //cac bit cho phep ngat sbit Ngat = 0xAF; //EA sbit NgatDinhthoi0 = 0xA9;
//DINH NGHIA CAC THAM SO KICH THUOC BANG, THOI GIAN QUET#define BeRong 4 //so byte cua mot hang #define BeRong 4 //so byte cua mot hang
#define ChieuCao 16 //so hang
#define SoByteMang 64 //so byte cua mang hien thi X #define SoLanNgat 5 //so lan say ra ngat dinh thoi #define SoDemDinhThoi 256 //so xung nhip dinh thoi can dem // bang du lieu khoi tao
// 16 11 1985
char data X[SoByteMang] = { 0x00,0x00,0x00,0x00,
0x00,0x00,0x06,0x00, 0x00,0x00,0x49,0x00, 0xFF,0xFF,0x49,0xFF, 0x40,0x40,0x49,0x40, 0x20,0x20,0x25,0x20, 0x00,0x00,0x1E,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x8c,0x6E,0x7C,0x00, 0x92,0x91,0xA2,0x00, 0xA1,0x91,0x91,0xFF, 0xA1,0x91,0x91,0x40, 0xA1,0x91,0x91,0x20, 0x72,0x6E,0x62,0x00, 0x00,0x00,0x00,0x00 }; /*---*/
int ChiSo,n;//chi so mang va bien n de dem so lan say ra ngat /*---*/
#pragma NOAREGS // ko su dung cac ky hieu thanh ghi tuyet doi cho cac // ham duoc goi tu dich vu ngat
/*---*/
static void XuLiNgatDinhThoi0 (void) //xuat ra mot hang thu x /*day la chuong chinh con phuc vu ngat dinh thoi 0
nhiem vu cua chuong trinh con nay la: - dem so lan say ra ngat dinh thoi qua bien n - khi n < 100 thi tang len 1 ket thuc