I am using an atmega328p and writing firmware to display the data I receive via i2c in putty.
I read the data I receive as follows:
/* Receive data from slave. */
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA);
while(!(TWCR & (1<<TWINT)));
libuart_send((char*)TWDR,1);
where:
void libuart_send(unsigned char *data, int data_size)
{
for(int i = 0; i < data_size; i++)
{
/* Wait for empty transmit buffer */
while ( !( UCSR0A & (1<<UDRE0)) );
/* Put data into buffer, sends the data */
UDR0 = data[i];
}
}
I can see with my logic analyzer that I receive 0x00:
Yet when trying to see the corresponding data with putty, I just get a weird symbol as if I am casting it incorrectly:
I have been trying to find out how the register TWDR
is defined in order to try to understand whether or not I am casting something incorrectly, but I didn't find the information I was looking for. Note that my function libuart_send
works perfectly fine when I do something like this libuart_send('A', 1);
, but not when I replace the first argument by TWDR. In other words the baudrate is perfectly fine.
Does anybody know why I am seing this weird character in stead of the number 0 in putty?
Thanks