In the debugger, I see that the pointer has the right address that I want and the variables
UBRR_VAL, val1, val2 hold the passed in values. Only problem is that the variables inside the struct _UBRRH, _UBRRL, _UCSRA and _UCSRB are not changing. Below you will find code snippets for reference. Thanks.
This is how the struct is defined
typedef uint8_t volatile DEVICEREGISTER;
typedef struct
{
DEVICEREGISTER _UDR;
DEVICEREGISTER _UCSRA;
DEVICEREGISTER _UCSRB;
DEVICEREGISTER _UBRRL;
} uart_register_t;
#define _USART (uart_register_t*) 0x2C
This is how I am calling the function.
uart_init(UBRR_VAL, 0, (1<<_TXC)|(1<<_RXC), _USART); // initialize the uart for outputting and inputting.
Below is the function definition.
void uart_init(uint8_t UBRR_VAL, uint8_t val1, uint8_t val2, uart_register_t *pointer)
{
pointer->_UBRRL = UBRR_VAL;
pointer->_UCSRA = val1;
pointer->_UCSRB = val2;
}
I appreciate everybody’s feedback on this question. It helped me narrow down the issue and finally resolved it. It turns out I had the variables inside the struct in the wrong sequential order. I fixed that problem now. Thank you very much for helping me resolve this issue!