PDA

View Full Version : [HELP] PIC 16f887 + 74HC595


saobang
27-04-2013, 11:27 AM
Mấy anh chị xem giùm em đoạn code này sai chỗ nào giúp em:
Em muốn hiển thị 3 số lên 3 led 7 đoạn mà nó ko chạy.
[CODE]
#include <16f887.h>
#device *=16 ADC=8
#use delay(clock=20000000)
#fuses HS
#define DATA PIN_D1
#define SCK PIN_D0
#define SCL PIN_D2
void truyen();
unsigned char ma[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
void truyen(unsigned char tram, unsigned char chuc, unsigned dv)
{
unsigned Q,i,temp;
Q=tram;for(i=0;i<8;i++){temp=(Q&0x80);if (temp==1)output_high(DATA);else output_low(DATA);output_low(SCK);output_high(SCK); Q<<=1;}
Q=chuc;for(i=0;i<8;i++){temp=(Q&0x80);if (temp==1)output_high(DATA);else output_low(DATA);output_low(SCK);output_high(SCK); Q<<=1;}
Q=dv; for(i=0;i<8;i++){temp=(Q&0x80);if (temp==1)output_high(DATA);else output_low(DATA);output_low(SCK);output_high(SCK); Q<<=1;}
output_high(SCL);output_low(SCL);
}
void main()
{
while (true)
{
truyen(ma[5],ma[4],ma[8]);
}
}
[CODE]/
mấy anh chị xem giúp em!