程序的意思为:在16个膜冲过后,在第一个595的输出端输出数组cm[]的第i个字节,在第二个595的输出端输出数组cn[]的第i个字节. 遇到问题:我发现两个595的Q0,Q4端都没有波形,为底电平.(绝对没有虚焊的问题)请大家指导!
#include <reg52.h> #include <intrins.h> #include <absacc.h> #define uchar unsigned char #define uint unsigned int
sbit SER = P3^0; sbit SRCLK = P3^1; sbit RCK = P3^5; uchar data cm[5]={0x31,0x02,0x56,0x45,0x12}; uchar data cn[5]={0x33,0x34,0x54,0x43,0x14};
void Write595(uchar val,uchar val2); void main(void) { uchar i;
while(1) { for (i=0;i<5;i++) { Write595(cm,cn); } } } void Write595(uchar val,uchar val2) { uchar i; for (i=0;i<8;i++) { SRCLK=0; SER=(bit)(val&0x01); val=val>>1; SRCLK=1; }
for (i=0;i<8;i++) { SRCLK=0; SER=(bit)(val2&0x01); val2=val2>>1; SRCLK=1; } RCK =0; _nop_(); _nop_(); RCK =1; } |