我正在使用PIC18处理器开发一个随机数生成器。
如果按下按钮,并且我的模拟器在Proteus中显示错误消息,则不会显示数字:
[PIC18] PC=0x0000. $MCLR$ is low. Processor is in reset. [U1]
这是我的代码:
#pragma config MCLRE=OFF
sbit DIS1 at PORTD.B6; //Define Display 1 at Port D pin RD 6
sbit DIS2 at PORTD.B7; //Define Display 2 at Port D pin RD
unsigned char Code[10]={0x40, 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78, 0x00, 0x10};
unsigned char DEC, DIG, DEL; //Define variable
void MSDelay (unsigned char Time) //Delay
{
unsigned char y,z; //Define variable
for (y=0; y<Time; y++) //For loop for Delay
for (z=0; z<254; z++); //For loop for Delay
}
void main () //Main Function
{
TRISC = 0;//Define PORTC as Output Port
TRISD.RD6 = 0; //Define RD6 as Output Pin
TRISD.RD7 = 0; //Define RD7 as Output Pin
DIS1= 0;//Turn OFF Display 1
DIS2= 0; //Turn OFF Display
while (1) //End-Less Loop
{
for (DEC=0; DEC<10;DEC++)
{
for (DIG=0; DIG<10; DIG++) //For Loop for Display Digit Number
{
for (DEL=0; DEL<10; DEL++) //Delay for next digit
{
DIS1 = 1; //Turn ON Display 1
PORTC = Code [DEC]; //Find code and send to the PORTC
MSDelay(10) ; //Delay for Turning ON the display
DIS1 = 0; //Turn OFF Display I
DIS2 = 1; //Turn ON Display
PORTC= Code [DIG]; //Find code and send to the PORTC
MSDelay (10) ; //Delay for Turning ON the display
DIS2 = 0;//Turn OFF Display 2
}
}
}
}
}有什么问题吗?
发布于 2022-01-22 11:28:29
PIC18 PC=0x0000.$MCLR$较低。处理器处于重置状态。U1 #杂注配置MCLRE=OFF
并非所有模拟器都支持微控制器配置(#pragma config)。
我甚至在微芯片网站上找到了论坛条目,这可能不适用于真正的微控制器!
"$MCLR$很低,处理器正在重置。“意味着您的模拟器不关心#pragma config MCLRE=OFF行。
你有很多没用的别针。我会使用不同的引脚(例如,RE0而不是RE3)。
就我个人而言,我也不会改变一个真正的微控制器(#pragma config)的控制器配置,除非它是真正必要的:
如果出了什么问题,你可以砖头的微控制器,它不能再使用了。
https://stackoverflow.com/questions/70812156
复制相似问题