熱門: 51單片機(jī) | 24小時(shí)必答區(qū) | 單片機(jī)教程 | 單片機(jī)DIY制作 | STM32 | Cortex M3 | 模數(shù)電子 | 電子DIY制作 | 音響/功放 | 拆機(jī)樂園 | Arduino | 嵌入式OS | 程序設(shè)計(jì)
|
發(fā)布時(shí)間: 2016-2-29 18:01
正文摘要:[img]file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/1464216403/QQ/WinTemp/RichOle/[FFDS~[ZUZ)%605G6RMQ[KL$7.png[/img] 求助!有哪位大神知道MBI5026芯片怎么驅(qū)動(dòng), ... |
本帖最后由 liu_qing532 于 2016-3-12 15:55 編輯 ![]() ![]() 終于可以顯示:#include<reg51.h> #define uchar unsigned char #define uint unsigned int sbit MBI_SDIG=P3^4; sbit MBI_SDIR=P3^2; sbit MBI_CLK=P3^5; sbit MBI_LE=P3^7; uint code Tab[]= { 0xd680, // 0 0x5000, // 1 0xc620, // 2 0xd420, // 3 0x50a0, // 4 0x94a0, // 5 0x96a0, // 6 0xd000, // 7 0xd6a0, // 8 0xd4a0 // 9 }; void delay(uint xms) { uint i,j; for(i=xms;i>0;i--) for(j=100;j>0;j--); } void mbi5026(uint dat) { uint k; for(k=0;k<16;k++) { MBI_SDIR=(dat &0x8000)?1:0; MBI_CLK=1; dat<<=1; MBI_CLK=0; } MBI_LE = 1; delay(1000); MBI_LE = 0; } void main() { uchar q; MBI_CLK=0; MBI_SDIR=0; MBI_SDIG=0; for(q=0;q<10;q++) { mbi5026(Tab[q]); delay(1000); } } 只能顯示零星的字段,不能顯示完整數(shù)字,求大神告知是哪錯(cuò)了???數(shù)組編碼應(yīng)該不會(huì)錯(cuò),對(duì)了好幾遍了。 |
nsj21n 發(fā)表于 2016-3-1 15:03 #include<reg51.h> #define uchar unsigned char #define uint unsigned int sbit MBI_SDIG=P3^4; sbit MBI_SDIR=P3^2; sbit MBI_CLK=P3^5; sbit MBI_LE=P3^7; //顯示段碼表 uchar code Tab[]= { 0xdfc0, // 0 0x03c0, // 1 0xc620, // 2 0x86a0, // 3 0x12a0, // 4 0x94a0, // 5 0xd4a0, // 6 0x0680, // 7 0xd6a0, // 8 0x96a0, // 9 }; void delay(uint xms) { uint i,j; for(i=xms;i>0;i--) for(j=100;j>0;j--); } void mbi5026(uchar dat) { uchar k; for(k=0;k<16;k++) { MBI_SDIR=(dat &0x8000)?1:0; MBI_CLK=1; dat<<=1; MBI_CLK=0; } MBI_LE = 1; delay(100); MBI_LE = 0; } void main() { uchar q; MBI_CLK=0; MBI_SDIR=0; MBI_SDIG=0; for(q=0;q<10;q++) { mbi5026(Tab[q]); delay(1000); } } 求教,大神!! |
|
MBI是16位串行數(shù)據(jù),你這樣確定能把數(shù)據(jù)送出去?給你個(gè)參考發(fā)送16位數(shù)據(jù),其它依照時(shí)序圖補(bǔ)上:for(i=0;i<16;i++) { MBI_SDI=(dat & 0x8000)?1:0; //串口移位的數(shù)據(jù) MBI_CLK=1; dat<<=1; delay(10); MBI_CLK=0; // delay(500); } |
nsj21n 發(fā)表于 2016-3-1 09:11 #include<reg51.h> #define uchar unsigned char #define uint unsigned int sbit MBI_SDI=P3^4; sbit MBI_CLK=P3^5; sbit MBI_LE=P3^7; uchar num; //顯示段碼表 uchar code Tab[]= { 0xdfc0, // 0 0x03c0, // 1 0xc620, // 2 0x86a0, // 3 0x12a0, // 4 0x94a0, // 5 0xd4a0, // 6 0x0680, // 7 0xd6a0, // 8 0x96a0, // 9 }; void delayms(uint xms) { uint i,j; for(i=xms;i>0;i--) for(j=100;j>0;j--); } void main() { MBI_CLK = 0; MBI_SDI = 0; while(1) { for(num=9;num>0;num--) { MBI_SDI=Tab[num]; MBI_CLK=1; MBI_CLK=0; MBI_LE=1; delayms(1000); MBI_LE=0; } } } 初學(xué),哪里錯(cuò)?? |
| 程序?qū)懗鰜砹嗣?先參考時(shí)序圖寫寫貼出來大家給你參考 |
Powered by 單片機(jī)教程網(wǎng)