Oh.
Hello, friends.
In this short lesson we will send the string from microcontroller to PC .
We will receive the string by terminal TERMITE.
Let's look the program.
When we are pressing the button 3
We call the function
send_Uart_string(*s),
In our case, we want to send the word hello.
Here is this function.
In this function in loop "for" we send characters one by one from zero to last character of string.
To find the last character, we use the standard library function
strlen(s),
In loop for
we are waiting while UDRE will set to 1
And after this
uploading the character to UDR register
We do it for i=0,
after this increase i
And we do it for each i one by one.
I am pressing the button 3
and send the word
Hello.
to terminal TERMITE
OK, now you know how to send the data from microcontroller, let's receive the data from PC.
The simplest
to use Receiver Complete Interrupt.
For run the interrupt handler, need to set to 1 the RXCIE
bit
in UCSRB register.
Let's look the handler.
When UDR
register is full
we can read this register.
After this we send by UART the string "ok!" and after this we send
this variable
plus one.
Let's try.
For example, we will send
number two.
Send.
We receive Ok!
And we receive No.
Two plus one.
We receive three.
OK, let's send 5.
OK, nice.. We receive 6
Ok!
Everything is working.
Thank you for your time.
Oh.