完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
利用单片机控制MAX7456实现视频信号与字符叠加,求问大神有没有对MAX7456比较熟悉的,写的程序好像不能用~~
下面是我写的程序~哪里有问题~ #include "reg52.h" #include //MAX7456寄存器定义 #define MAX7456_VM0_write 0x00 #define MAX7456_VM0_read 0x80 #define MAX7456_VM1_write 0x01 #define MAX7456_VM1_read 0x81 #define MAX7456_HOS_write 0x02 #define MAX7456_HOS_read 0x82 #define MAX7456_VOS_write 0x03 #define MAX7456_VOS_read 0x83 #define MAX7456_DMM_write 0x04 #define MAX7456_DMM_read 0x84 #define MAX7456_DMAH_write 0x05 #define MAX7456_DMAH_read 0x85 #define MAX7456_DMAL_write 0x06 #define MAX7456_DMAL_read 0x86 #define MAX7456_DMDI_write 0x07 #define MAX7456_DMDI_read 0x87 #define MAX7456_CMM_write 0x08 #define MAX7456_CMM_read 0x88 #define MAX7456_CMAH_write 0x09 #define MAX7456_CMAH_read 0x89 #define MAX7456_CMAL_write 0x0A #define MAX7456_CMAL_read 0x8A #define MAX7456_CMDI_write 0x0B #define MAX7456_CMDI_read 0x8B #define MAX7456_OSDM_write 0x0C #define MAX7456_OSDM_read 0x8C #define MAX7456_RB0_write 0x10 #define MAX7456_RB0_read 0x90 #define MAX7456_RB1_write 0x11 #define MAX7456_RB1_read 0x91 #define MAX7456_RB2_write 0x12 #define MAX7456_RB2_read 0x92 #define MAX7456_RB3_write 0x13 #define MAX7456_RB3_read 0x93 #define MAX7456_RB4_write 0x14 #define MAX7456_RB4_read 0x94 #define MAX7456_RB5_write 0x15 #define MAX7456_RB5_read 0x95 #define MAX7456_RB6_write 0x16 #define MAX7456_RB6_read 0x96 #define MAX7456_RB7_write 0x17 #define MAX7456_RB7_read 0x97 #define MAX7456_RB8_write 0x18 #define MAX7456_RB8_read 0x98 #define MAX7456_RB9_write 0x19 #define MAX7456_RB9_read 0x99 #define MAX7456_RB10_write 0x1A #define MAX7456_RB10_read 0x9A #define MAX7456_RB11_write 0x1B #define MAX7456_RB11_read 0x9B #define MAX7456_RB12_write 0x1C #define MAX7456_RB12_read 0x9C #define MAX7456_RB13_write 0x1D #define MAX7456_RB13_read 0x9D #define MAX7456_RB14_write 0x1E #define MAX7456_RB14_read 0x9E #define MAX7456_RB15_write 0x1F #define MAX7456_RB15_read 0x9F #define MAX7456_OSDBL_write 0x6C #define MAX7456_OSDBL_read 0xEC #define MAX7456_STAT 0xA0 #define MAX7456_DMDO 0xB0 #define MAX7456_CMDO 0xC0 //单片机接口 ***it CS=P1^0; ***it SDIN =P1^1; ***it SCLK =P1^2; ***it SDOUT =P1^3; //***it button =P1^5; //***it RESET =P1^7; void MAX7456_RESET(); void MAX7456_write_addr_data(unsigned char,unsigned char); unsigned char MAX7456_read_addr_data(unsigned char); void MAX7456_turnoff_display(); void MAX7456_display(unsigned char,unsigned char,unsigned char); void C52_delay_ms(unsigned char); void C52_delay_us(); void main() { /*while(1) { if(1) { C52_delay_ms(20); if(1) { MAX7456_display(0x01,0x01,0x0c); // } } else { C52_delay_ms(20); if(0) { MAX7456_turnoff_display(); } } }*/ while(1) { MAX7456_display(0x01,0x01,0x0c); // C52_delay_ms(200); C52_delay_ms(200); C52_delay_ms(200); C52_delay_ms(200); C52_delay_ms(200); } } void C52_delay_ms(unsigned char x) { unsigned char y,z; for(y=0;y for(z=0;z<111;z++); } } void C52_delay_us() { ; } /*void MAX7456_RESET() { RESET=0; C52_delay_ms(1); RESET=1; C52_delay_ms(100); }*/ unsigned char MAX7456_read_addr_data(unsigned char addr) 读数据操作 { unsigned char byte=0; unsigned char i,temp; unsigned char j; CS=1; SCLK=0; //C52_delay_ms(1); ; CS=0; //C52_delay_ms(1); for(i=0;i<8;i++) { //SCLK=0; temp=addr&0x80; if(temp==0x80) { SDIN=1; //C52_delay_us(); } else { SDIN=0; //C52_delay_us(); } SCLK=1; SCLK=0; addr<<=1; } SCLK=0; byte=0; for(j=0;j<8;j++) { byte<<=1; //byte=(byte<<1)|SDOUT; //SCLK=0; //C52_delay_us(); SCLK=1; byte =(unsigned char)SDIN+byte; SCLK=0; } CS=1; return byte; } void MAX7456_write_addr_data(unsigned char addr,unsigned char dt) //写 { unsigned char i,temp; CS=1; SCLK=0; //C52_delay_ms(1); //temp=addr; CS=0; //C52_delay_ms(1); for(i=0;i<8;i++) { //SCLK=0; temp=addr&0x80; if(temp==0x80) { SDIN=1; //C52_delay_us(); } else { SDIN=0; //C52_delay_us(); } SCLK=1; SCLK=0; addr<<=1; } //SCLK=0; //C52_delay_ms(1); //CS=0; //C52_delay_ms(1); for(i=0;i<8;i++) { //SCLK=0; temp=dt&0x80; if(temp==0x80) { SDIN=1; //C52_delay_us(); } else { SDIN=0; //C52_delay_us(); } SCLK=1; SCLK=0; dt<<=1; } CS=1; SDIN=0; } void MAX7456_turnoff_display()//¹Ø±ÕÏÔʾ { unsigned char i; unsigned char j; i=MAX7456_read_addr_data(MAX7456_VM0_read); MAX7456_write_addr_data(MAX7456_VM0_write,i&~(1<<3)); for(j=0;j<20;j++) { C52_delay_us(); } } void MAX7456_display(unsigned char row,unsigned char col,unsigned char c) //c为地址 { unsigned int num; unsigned char temp; num=row*30+col; MAX7456_write_addr_data(MAX7456_DMM_write,MAX7456_read_addr_data(MAX7456_DMM_read)|1<<2); // while(MAX7456_read_addr_data(MAX7456_DMM_read)>>2%2){}; temp=MAX7456_read_addr_data(MAX7456_DMM_read); MAX7456_write_addr_data(MAX7456_DMM_write,temp|0x40); MAX7456_write_addr_data(MAX7456_DMAH_write,MAX7456_read_addr_data(MAX7456_DMAH_read)&(~(1<<1)));// MAX7456_write_addr_data(MAX7456_DMAH_write,(num/256)&(0xFD));// MAX7456_write_addr_data(MAX7456_DMAL_write,num%256); while(MAX7456_read_addr_data(MAX7456_DMM_read)>>2%2){}; MAX7456_write_addr_data(MAX7456_DMDI_write,c);// while(MAX7456_read_addr_data(MAX7456_STAT)>>5%2|MAX7456_read_addr_data(MAX7456_DMM_read)>>2%2){}; //MAX7456_write_addr_data(MAX7456_VM0_write,MAX7456_read_addr_data(MAX7456_VM0_read)|(0x01<<3)); // while(MAX7456_read_addr_data(MAX7456_STAT)>>5%2|MAX7456_read_addr_data(MAX7456_DMM_read)>>2%2){} MAX7456_write_addr_data(MAX7456_VM0_write,0x08); MAX7456_write_addr_data(MAX7456_OSDBL_write,MAX7456_read_addr_data(MAX7456_OSDBL_read)&(~(0x01<<4))); } |
|
相关推荐
1 个讨论
|
|
准备做一个电子diy将太阳能和led结合起来,大家有什么好的创意吗?
3381 浏览 0 评论
22099 浏览 180 评论
1495 浏览 0 评论
5497 浏览 1 评论
分享一个比较好的编码器模式的程序 自己曾经做过倒立摆的程序 亲测好用
8769 浏览 24 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-14 12:00 , Processed in 0.667107 second(s), Total 41, Slave 31 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (威廉希尔官方网站 图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号