Closed Someone-s-out-there closed 8 months ago
Describe the bug currently the uart rx is not working as intended. it doesnt seem to receive the characters
To Reproduce Steps to reproduce the behavior:
What has already been tried Note down what has already been tried
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
code block one
#define F_CPU 16000000ul #include <avr/io.h> #include <stdint.h> #include<util/delay.h> #include"libUart.h" int main(void){ //DDRB |= (1<<DDB5)|(1<<DDB4)|(1<<DDB3)|(DDB2)|(DDB1); DDRB |= (0x3F); uart_init(); PORTB = 0x01; RXBuff_t buffer; uart_set_rxBuffer(&buffer); while (1) { if(buffer.linecomplete){ uart_puts(buffer.buffer); buffer.buffer_IDX = 0; buffer.linecomplete = 0; } _delay_ms(100); } }
code block 2
extern char uart_outbuf[UART_RX_BUFFER_SIZE + 1]; extern char uart_rxbuf[UART_RX_BUFFER_SIZE + 1]; extern volatile unsigned char uart_rx_linecomplete; extern volatile unsigned char uart_rx_pos; // end of string in rx ISR(USART_RX_vect) { unsigned char c; c = UDR0; // Fetch the received byte value into the variable "ByteReceived" //UDR0 = c; // Echo back the received byte back to the computer uart_rxbuf[uart_rx_pos] = c; //UDR0 = c; if ((c == '\n') || (uart_rx_pos > UART_RX_BUFFER_SIZE - 1)) { uart_rxbuf[uart_rx_pos] = 0; strcpy(uart_outbuf, uart_rxbuf); uart_rx_linecomplete = 1; } else { uart_rx_pos++; } }
currently testing with just echoing the character back. by reading adn writing, interrut not working needs testing with SEI() macro
needed marking of variables as volatile
Describe the bug currently the uart rx is not working as intended. it doesnt seem to receive the characters
To Reproduce Steps to reproduce the behavior:
What has already been tried Note down what has already been tried
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
code block one
code block 2