Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

uart problem?

Altera_Forum
Honored Contributor II
948 Views

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!=&#39;$&#39;);  

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"); 

 

}
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
257 Views

Please look at P4-7 P4-8 in Nios II SW handbook (n2sw_nii5v2.pdf)

0 Kudos
Altera_Forum
Honored Contributor II
257 Views

thank you for your answer! yes i see,but time alarms like ISRs run in a restricted environment.for example:accesses to the HAL file system are not permitted. what&#39;s your meaning?

0 Kudos
Reply