Browsing this Thread:
1 Anonymous Users
|
PIC与MCP41010通讯问题
|
|
新會員
Joined
: 2008/7/30 15:49 最後登入時間
: 2008/7/30 15:49
Group:
註冊會員
Level : 1 HP : 0 / 0 MP : 0 / 0 EXP : 0
|
void spiinit() { PIR1 = 0; SSPCON = 0x20; //工作在主控下,无效为低电平 00100000 SSPSTAT = 0x00; //00000000
TRISC3 = 0; TRISC4 = 1; //sdo输出,sck输出,SDI输入,rc6.rc7输出 TRISC5 = 0; TRISC6 = 0; TRISC7 = 0 ; TRISA5 = 0; }
这里要往mcp41010数字电位器写数,mcp41010支持0.0 和1.1俩个模式,下面是数据发送函数之前cs已经拉低,在下面俩个函数后拉高,这里出现了一个奇怪问题,SSPBUF = 0x11,这里的赋值不起作用,在watch中观察始终为0x00,软件调试就没有这个问题.不知道那位老师能解答一下为什么?
void spisetcom() { SSPBUF = 0x11; //mcp41010命令
do { ; } while(SSPIF==0); //等待发送完毕
SSPIF=0;
} void spisetdata() { SSPBUF = data; data++; do { ; } while(SSPIF==0); //等待发送完毕
SSPIF=0; } 示波器上sdo引脚与cs引脚有输出
發表於: 2008/7/30 15:53
|
|
You can view topic.
你 不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.