Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

uart 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!=&#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");

}

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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?