关于68908QT4仿真状态下读不出中断采样ad值
- UID
- 132821
- 性别
- 男
|
关于68908QT4仿真状态下读不出中断采样ad值
各位大虾我遇到问题如下:
1:在仿真环境下 在主程序里设断点却读不到全局变量advv传回的AD中断方式采样的值,而在AD终端里可以读到AD值得变化,如脱机运行则正常 为何?环境CW3.1,
2:脱机上电运行有时跑起来,有时跑不起来为何?
请给为大虾赐教谢谢! |
|
|
|
|
|
- UID
- 132821
- 性别
- 男
|
void #include "hidef.h"
#pragma DATA_SEG SHORT _DATA_ZEROPAGE
// I/O register definition
volatile unsigned char PTA @0x0000; // Port A data register
volatile unsigned char DDRA @0x0004; // Port A data direction register
volatile unsigned char CONFIG2 @0x001E; // Configuration register 2
volatile unsigned char CONFIG1 @0x001F; // Configuration register 1
volatile unsigned char OSCSTAT @0x0036; // Oscillator status register
volatile unsigned char ADSCR @0x003C; // ADC status and control register
volatile unsigned char ADR @0x003E; // ADC data register
volatile unsigned char ADICLK @0x003F; // ADC data register
static unsigned char advv;
void delay (unsigned char dly)
{
int i;
do
{
for(i=0; i<100; i++)
;
}
while(dly-- > 0);
}
void main (void)
{
// unsigned char flg;
// int cnt,ad1,ad2;
// flg=0;
// cnt=0;
CONFIG1 |= 0x09; // Disables COP
CONFIG2 = 0x40; // Enables external oscillator and RESET pin
OSCSTAT = 0x00; // Enables external clock generator
DDRA |= 0x0; // PTA1 = LED output 0X0B PTA3 OUT
ADSCR = 0x03; // Enables ADC channel 2
ADICLK=0x96;
EnableInterrupts // Enables Global Interrupt
ADSCR = 0x42;
|
|
|
|
|
|
- UID
- 132821
- 性别
- 男
|
for(;;) // Forever
{
delay (advv); // Uses the ADC value (in ms) to perform a delay
PTA ^= 0x8; // Toggles user LED
}
}
void irq_isr (void)
{
asm {
wait_irq:
bil wait_irq ; Waits for the IRQ signal to go high
jmp $0FE1A ; Jumps to monitor code
}
}
interrupt 16 void irq_ad(void)
{
static unsigned char adval,lkk;
adval=0;
lkk=12;
adval=ADICLK;
adval=ADR;
lkk=lkk+adval;
advv=(adval>>1);
ADSCR = 0x42;
}
|
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
|
|
|
|
|
- UID
- 132821
- 性别
- 男
|
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
|
|
|
|
|
- UID
- 132821
- 性别
- 男
|
可以ADC中断程序读去正确的值,为何在主循环里读不到?
|
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
看看你的变量在主程序和中断程序中是否指向同一地址? |
|
|
|
|
|
- UID
- 132821
- 性别
- 男
|
|
|
|
|
|
- UID
- 132821
- 性别
- 男
|
|
|
|
|
|