Altera_Forum
Honored Contributor
21 years agouart problem?
hello!i want to receive data from uart1 every 3 sec,i use the time alarm,the data send 1 sec every time,but i found that the data missing seriously! for examle:the rigth data should be:123456789 but i received from the uart1 is:13579,the band is 4800 and it can't be changed !why?help!
the programm is below:# include <stdio.h># include <string.h># include <unistd.h># include "system.h"# include "alt_types.h"# include "sys/alt_alarm.h"# include "altera_avalon_uart_regs.h" static alt_alarm alarm1; alt_u32 my_alarm(void *content) {int i; char rd; char *rc1; printf("it is timer\n"); do { rd=IORD_ALTERA_AVALON_UART_RXDATA(UART1_BASE); } while(rd!='$'); IOWR_ALTERA_AVALON_UART_TXDATA(UART1_BASE, rd); printf("receive:%c\n",rd); for(i=0;i<50;i++) { rd=IORD_ALTERA_AVALON_UART_RXDATA(UART1_BASE); rc1=rd;
}
for(i=0;i<50;i++)
printf("%c",rc1); printf("\n"); return 3*alt_ticks_per_second(); } int main() { if(alt_alarm_start(&alarm1,1000,my_alarm,NULL)<0) printf("it is error!\n"); }