|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2015-6-29 17:08:44
|
显示全部楼层
#include "avr/io.h"
#include "avr/interrupt.h"
#include "pgmspace.h"
#include "my_usart.h"
#define F_CPU 16000000UL
volatile unsigned char temp[1024]={0};
volatile unsigned char temp1[30]={0},temp2[18]={0};
volatile unsigned char temp3=0,i;
SIGNAL(USART1_RX_vect)
{
temp3=UDR1;
switch(temp3)
{
case 0xff:
USART1_READ_BYTES(temp1,30);
break;
case 0xAB:
for (i=0;i<16;i++)
{
temp2=temp1[i+10];
}
USART1_WRITE_BYTES(temp2,18);
break;
default:
break;
}
}
int main(void)
{
USART_Init();
DDRA=0xff;
PORTA=0xff;
sei();
while(1)
{
PORTA ^= (1<<PA0);
//TODO:: Please write your application code
}
}
先从串口读30个数据,之后把第10-25个转存一次,收到AB之后从串口送出这些数据,第一次送出的是正确的,在发送一次就是全0 |
|