CAN总线控制器SJA1000初始化后INT总是低电平
本帖最后由 Lvren 于 2013-3-18 21:19 编辑SJA1000初始化INT总是低电平,不知道何解,请教有玩过CAN总线的大神,下面贴出初始化程序,因为INT总是低电平的问题无法解决,导致后续自检测的实验无法进行,急求!
#include<reg52.h>
#include<absacc.h>
#include<sja1000.h>
#define LCD P0
#define uchar unsigned char
sbit RS=P2^5;
sbit RW=P2^6;
sbit E=P2^7;
sbit aa=P0^0;
sbit bb=P0^1;
void Delay(uchar t1,uchar t2)
{
for(;t1>0;t1--)
for(;t2>0;t2--);
}
/**************SJA1000初始化**********************/
SJA1000_Init()
{
uchar i;
MODE=0x01;
CDR=0x88;
IER=0x00;
ACR0=0x00;
ACR1=0x20;
ACR2=0x00;
ACR3=0x00;
AMR0=0x00;
AMR1=0x00;
AMR2=0xff;
AMR3=0xff;
BTR0=0x00;
BTR1=0x14;
OCR=0xaa;
TXERR=0x00;
i=ECC;
MODE=0x00;
}
/**************LCD写数据**********************/
void Lcd_WD(uchar da)
{
RS=1;
RW=0;
E=1;
LCD=da;
Delay(1,100);
E=0;
}
/**************LCD写命令**********************/
void Lcd_WC(uchar c)
{
RS=0;
RW=0;
E=1;
LCD=c;
Delay(1,100);
E=0;
}
/**************LCD初始化**********************/
void Lcd_Init()
{
Delay(15,125);
Lcd_WC(0x38);
Delay(5,125);
Lcd_WC(0x38);
Delay(5,125);
Lcd_WC(0x38);
Delay(5,125);
Lcd_WC(0x08);
Lcd_WC(0x01);
Lcd_WC(0x06);
Lcd_WC(0x0c);
}
/**************LCD写字符串**********************/
void WriteString(uchar *s)
{
uchar i;
if(*s=='\0')
return;
for(i=0;;i++)
{
if(*(s+i)=='\0')
break;
Lcd_WD(*(s+i));
}
}
/**************主程序**********************/
void main()
{
uchar *s1="success";
uchar *s2="error";
Delay(255,25);
Lcd_Init();
SJA1000_Init();
Lcd_WC(0x80);
Delay(255,255);
if(SR==0x0C)
// aa=0;
WriteString(s1);
else
// bb=0;
WriteString(s2);
while(1);
}
搞定了,是SJA1000的INT脚没接上拉电阻
页:
[1]