我是最近学单片机的萌新 我用的 两块74HC138级联加三极管 作为行驱动 两块74HC595级联作为列驱动 连接如图片所示
字符取码逐行式 低位在前 高位在后 我已经完成了 拉幕显示 从下往上移显示 现在问题是由于我是只能是逐行式扫描 我要怎么进行从右往左移显示啊 有点想不通 希望各位大神能给一点指点 编程的思路 万分感谢 我不想更改595和138的驱动程序
下面是我发送数据的595和138的驱动代码
void HC595_Data_Send(uchar daH,daL,hang) //¸高八位在点阵屏幕的右八位 因此我先移如高八位再移入第八位
{
uchar i;
Latch_port = 0;//关闭锁存器的存储寄存器 不输出数据
CLK_port = 0;//锁存器移位寄存器的时钟输入口置0
for(i=0;i<8;i++){
if((daH&0x80)!=0) DA_in_port = 1;
else DA_in_port = 0;
CLK_port = 1;
CLK_port = 0;
daH <<= 1;
}
for(i=0;i<8;i++){
if((daL&0x80)!=0) DA_in_port = 1;
else DA_in_port = 0;
CLK_port = 1;
CLK_port = 0;
daL <<= 1;
}
EN_port = 1; /关闭显示 使138输出全为1 点阵不显示
switch (hang){
case 0:
A_port = 0; B_port = 0; C_port = 0; D_port = 0; //D为0时 对应上八行有可能不显示
break;
case 1:
A_port = 1; B_port = 0; C_port = 0; D_port = 0;
break;
case 2:
A_port = 0; B_port = 1; C_port = 0; D_port = 0;
break;
case 3:
A_port = 1; B_port = 1; C_port = 0; D_port = 0;
break;
case 4:
A_port = 0; B_port = 0; C_port = 1; D_port = 0;
break;
case 5:
A_port = 1; B_port = 0; C_port = 1; D_port = 0;
break;
case 6:
A_port = 0; B_port = 1; C_port = 1; D_port = 0;
break;
case 7:
A_port = 1; B_port = 1; C_port = 1; D_port = 0;
break;
case 8:
A_port = 0; B_port = 0; C_port = 0; D_port = 1; //D为1时 下有可能八行显示
break;
case 9:
A_port = 1; B_port = 0; C_port = 0; D_port = 1;
break;
case 10:
A_port = 0; B_port = 1; C_port = 0; D_port = 1;
break;
case 11:
A_port = 1; B_port = 1; C_port = 0; D_port = 1;
break;
case 12:
A_port = 0; B_port = 0; C_port = 1; D_port = 1;
break;
case 13:
A_port = 1; B_port = 0; C_port = 1; D_port = 1;
break;
case 14:
A_port = 0; B_port = 1; C_port = 1; D_port = 1;
break;
case 15:
A_port = 1; B_port = 1; C_port = 1; D_port = 1;
break;
}
Latch_port = 1; //595数据输出到Q1---Q8端
EN_port = 0; /*138输出有效打开显示*/
Latch_port = 0; /*595输出锁定*/
}
|