Altera_Forum
Honored Contributor
15 years agoInterrupt Nios II RS232 / Usart
Hello!
I am trying to use the rs232 interrupt. sending and receiving data works fine, but when i try to use the interrupt to receive data I get some problems. this is the rs232 block in my system.h /* * uart_rs232 configuration * */ # define UART_RS232_NAME "/dev/uart_rs232" # define UART_RS232_TYPE "altera_avalon_uart" # define UART_RS232_BASE 0x0a201280 # define UART_RS232_SPAN 32 # define UART_RS232_IRQ 18 # define UART_RS232_IRQ_INTERRUPT_CONTROLLER_ID 0 # define UART_RS232_BAUD 9600 # define UART_RS232_DATA_BITS 8 # define UART_RS232_FIXED_BAUD 0 # define UART_RS232_PARITY 'N' # define UART_RS232_STOP_BITS 1 # define UART_RS232_SYNC_REG_DEPTH 2 # define UART_RS232_USE_CTS_RTS 0 # define UART_RS232_USE_EOP_REGISTER 0 # define UART_RS232_SIM_TRUE_BAUD 0 # define UART_RS232_SIM_CHAR_STREAM "" # define UART_RS232_RELATIVEPATH 0 # define UART_RS232_FREQ 100000000 # define ALT_MODULE_CLASS_uart_rs232 altera_avalon_uart //this is my context typedef struct { int number; }my_context; //This is my ISR void rs232_isr (void* context, alt_u32 interrupt_number) { printf("data gets in"); } //this I call in my main at first void main(){ char msg[4]="test"; int result; result=alt_irq_register (UART_RS232_IRQ, (void*)my_contex, rs232_isr); alt_irq_enable(UART_RS232_IRQ); do{ fp = fopen("/dev/uart_rs232", "w+"); if(fp) { //printf("Connected\n"); fwrite(msg, strlen(msg), 1, fp); //fprintf(fp, "Closing the UART file.\n"); fclose(fp); } else { printf("Error/dev/ttyS0\n"); } }while(1); } If I start the my program the rs232_isr is called I think one hundred times... I think the rs232_isr is called by the fwrite(..). Is there a method to recognize only the RXD without react everytime at TXD (text send).