|
我用的是meg162的板子,外扩32K的ram,只写了一个测试读写功能的小程序,却始终运行不正常。
程序如下:
// Target : M162
// Crystal: 11.0592Mhz
#include <iom162v.h>
#include <macros.h>
#define RUN_LIGHT PORTD|=0x10 //PC0 RUN LED light
#define RUN_BLACK PORTD&=0xEF //PC0 RUN LED black
unsigned int i;
extern unsigned char data[2000];
//define mappings
void mapping_init(void)
{
asm(
".area memory(abs)
"
".org 0x2000
"
" _data:: .blkb 2000
"
".text
"
);
}
void port_init(void)
{
PORTA = 0xff; //PA output
DDRA = 0xFF;
PORTB = 0xFF; //PB0-PB2 input, others output
DDRB = 0xb8;
PORTC = 0xf3; //PC output
DDRC = 0xFF;
PORTD = 0XeF;
DDRD = 0x72;
PORTE = 0x07;
DDRE = 0x00;
}
void InitSys()
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
MCUCR= 0x80;
EMCUCR = 0x00;
TIMSK= 0x00; //timer interrupt sources
ETIMSK=0x00;
GICR= 0x00;
PCMSK0=0x00;
PCMSK1=0x00;
SEI(); //re-enable interrupts
//all peripherals are now initialised
}
void main(void){
unsigned int j;
InitSys();
for (j=0;j<2000;j++){
data[j]=0xf0;
}
if (data[5]==0xf0) {RUN_LIGHT;} //读取数组某一位的值,如果与写入的一致,测试灯亮
}
程序运行的结果应该是测试灯直接变亮才对,可是它根本没反应
测试灯没有问题,已经检查过了
我翻过论坛上以前的帖子,数组的定义和操作没看出什么不同
实在想不出来是哪里的问题
我用的iccavr,马老师可以指点一下吗?
先行谢过。 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|