请教关于用meg32 做的逻辑分析仪的代码 部分 (采用论坛上的文件)
int main(){
uint8_t ram;
DATADIR = 0x00;
DATAOUT = 0x00;
LOCKDDR = (0x00|LE);
unlock;
UCSRA = 0x00;
UCSRB = 0x18;
UCSRC = 0x06;
UBRRH = 0;
UBRRL = 25;
while(1)
{
wait;
trig = UDR;
wait;
trig_en = UDR;;
wait;
fre_lo = UDR;
wait;
fre_hi = UDR;
wait; //µÈ´ýÔ¤´¥·¢Êý¾Ý
pre_trig = UDR;
wait; //µÈ´ýÔ¤´¥·¢Êý¾Ý
pre_trig = UDR;
wait; //µÈ´ý¹¤×÷ģʽ
mode = UDR;
clrTXC;
UDR = 'D';
waitTXC;
for(addr=0; addr<2048; addr++)
ram = 0;
switch(fre_hi)
{
case 2:
if(fre_lo == 0x04)
sample_num = 0;
if(fre_lo == 0x0a)
sample_num = 1;
if(fre_lo == 0x14)
sample_num = 2;
if(fre_lo == 0x28)
sample_num = 3;
if(fre_lo == 0x64)
sample_num = 4;
if(fre_lo == 0xc8)
sample_num = 5;
break;
case 3:
if(fre_lo == 0x32)
sample_num = 6;
if(fre_lo == 0x7d)
sample_num = 7;
if(fre_lo == 0xfa)
sample_num = 8;
break;
case 4:
if(fre_lo == 0x7d)
sample_num = 9;
if(fre_lo == 0xfa)
sample_num = 10;
break;
case 5:
if(fre_lo == 0x7d)
sample_num = 11;
if(fre_lo == 0xfa)
sample_num = 12;
break;
}
addr = 0;
switch(mode)
{
case 0:
start: if(sample_num > 12)
break;
addr = 0;
if(sample_num==0)
{
pre_trig = 8;
addr = 1;
while(1)
{
lock;
asm("nop");
asm("nop");
temp = DATAIN;
asm("nop");
asm("nop");
unlock;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
if(trig == (temp | trig_en))
break;
}
asm("nop");
asm("nop");
ram = temp;
asm("nop");
asm("nop");
while(1)
{
lock;
asm("nop");
asm("nop");
ram = DATAIN;
asm("nop");
asm("nop");
unlock;
asm("ldi r16,1");
asm("ldi r17,0");
asm("add r10,r16");
asm("adc r11,r17");
asm("nop");
asm("nop");
if(addr_hi==8)
break;
}
}
addr_lo = 0x00;
addr_hi = 8 - pre_trig;
for(;addr<2048;addr++)
{
clrTXC;
UDR=ram;
waitTXC;
}
}
}
如果我用的是2us 采集的话就是只有这部分代码,我现在有点不明白,看代码应该是先采集了2048 个数据后,然后在把这2048 个数据发送到 pc 端 处理的,,那在发送这2048 个数据的时候, 采集的线上还有其他的数据传输的话, 是不是就不能采集了呢 ?
源代码文件如下
点击此处下载 ourdev_423218.zip(文件大小:146K) (原文件名:meg32 分析仪.zip) 按这种方式做的逻辑分析仪 能否连续的采集数据呢 ? 还是没明白 ,,, 这个熔丝位怎么配置啊
页:
[1]