I have written a program that uses printf
statement to write to the TERMINAL program using serial communication. Now, for my actual code, I want to transfer the content of my register and display it on the terminal window. How do I do that?
The test code is:
#include <REG51F.H>
#include <stdio.h>
void main(void){
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 253; /* TH1: reload value for 1200 baud @ 16MHz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
while(1){
printf("Test\n");
}
}
Best Answer
This is how it's done for an AVR. The definitions of the functions are trivial:
And then you fire up
minicom
or some other serial console on the PC and communicate.