本帖最後由 Offer 於 2011-12-2 23:24 編輯
- #include <reg52.h>
- sbit SCK=P3^5; //CLK
- sbit SDA=P3^4; //Data
- sbit RST=P3^3; //CE
- sbit RESET=P3^2; //RESET
- unsigned char G1[8]= (0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x40);
- unsigned char G2[8]= (0x44,0x5c,0x8f,0x36,0x40,0x00,0x00,0x01);
- unsigned char G3[8]= (0xf2,0x4f,0xe1,0x24,0x00,0x00,0x00,0x02);
- unsigned char G4[8]= (0xf2,0x4f,0xe1,0x2c,0x30,0x00,0x00,0x03);
- unsigned char Count;
- /*復位腳*/
- #define RST_CLR RST=0/*電平置低*/
- #define RST_SET RST=1/*電平置高*/
- /*數據*/
- #define IO_CLR SDA=0/*電平置低*/
- #define IO_SET SDA=1/*電平置高*/
- /*時鐘信號*/
- #define SCK_CLR SCK=0/*時鐘信號*/
- #define SCK_SET SCK=1/*電平置高*/
- /*Reset信號*/
- #define RESET_CLR RESET=0/*時鐘信號*/
- #define RESET_SET RESET=1/*電平置高*/
- /*向DEON VFD寫入一字節數據*/
- void VFD_write_byte(unsigned char d)
- {
- unsigned char i;
- for (i = 0; i < 8; i ++)
- {
- if (d & 0x01)
- {
- IO_SET;
- }
- else
- {
- IO_CLR;
- }
- SCK_SET;
- SCK_CLR;
- d = d >> 1;
- }
- // RST_CLR; /*停止VFD總線*/
- }
- main()
- {
- while(1)
- {
- RESET_CLR;
- RST_CLR;
- VFD_write_byte(0x76);
- RST_SET;
- for (Count =0; Count < 8 ;Count++)
- {
- VFD_write_byte(G1[Count]);
- }
- RST_CLR;
- VFD_write_byte(0x76);
- RST_SET;
- for (Count =0; Count < 8 ;Count++)
- {
- VFD_write_byte(G2[Count]);
- }
- RST_CLR;
- VFD_write_byte(0x76);
- RST_SET;
- for (Count =0; Count < 8 ;Count++)
- {
- VFD_write_byte(G3[Count]);
- }
- RST_CLR;
- VFD_write_byte(0x76);
- RST_SET;
- for (Count =0; Count < 8 ;Count++)
- {
- VFD_write_byte(G4[Count]);
- }
- }
- }
複製代碼 |