Forum Discussion
Altera_Forum
Honored Contributor
15 years agoHelp With UART RS-232 IRQ NEEK
I work with the NEEK, i am new in altera products. I am learning.
I work with a data adquisition in rs232, but i want use the uart interrupt because i need do other processes. I have the basic code: # include <stdio.h> # include <string.h> # include <sys/alt_alarm.h> # include "system.h" # include "alt_types.h" # include "sys/alt_cache.h" # include "sys/alt_irq.h" # include "altera_avalon_pio_regs.h" # include "io.h" # include "altera_avalon_uart_regs.h" # include "altera_avalon_uart.h" int main(){ FILE*fp; fp = fopen ("/dev/uart1", "r+"); // abro el puerto uart1 int prompt; while(1){ prompt = getc(fp); // obtengo caracter dell UART. } fclose (fp); //Cierro el Puerto } and I want convert the previous code in this: # include <stdio.h> # include <string.h> # include <sys/alt_alarm.h> # include "system.h" # include "alt_types.h" # include "sys/alt_cache.h" # include "sys/alt_irq.h" # include "altera_avalon_pio_regs.h" # include "io.h" # include "altera_avalon_uart_regs.h" # include "altera_avalon_uart.h" /// what I do in this place? void isr_uart1()// when uart1 rs232 interrupt make this process automatic { int prompt; prompt = getc(fp); } int main() { /// how I do enable the interrupt in this place? while(1){ // my process } } thanks, if someone can help me with code.2 Replies
- Altera_Forum
Honored Contributor
You can't use the stdio functions (eg getc) from any interrupt routines. In any case the UART interrupt is probably already used to put characters into teh stdio buffer.
You might be better looking at whether you can request non-blocking IO. I don't know if the Altera stdio does line buffering - which you also need to disable. - Altera_Forum
Honored Contributor
I need help to do this with interruptions because i need capture a data while i do other things.
I have my SOPC and in the SOPC, I put a Uart"Rs232", I need activate the interrupt of this uart, but how? when arrive data of rs232, I need do a process for the data, but i need continue with the others processes. :confused: