John99407
Junior Member level 3
0x41 is the ASCII code for 'A' I want to show "41" on hyper terminal without putch function and any other library
How can 41 shown on hyper terminal
How can 41 shown on hyper terminal
C:
//PIC16F877A MPLAB XC8
// CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT enabled)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
// End of configuration
#include <xc.h>
#define _XTAL_FREQ 20000000
#define Baud_rate 9600
void Initialize_UART(void) //Initializing UART module for PIC16F877A
{
TRISC6 = 0; // TX Pin set as output
TRISC7 = 1; // RX Pin set as input
/**Initialize SPBRG register for required
baud rate and set BRGH for fast baud_rate**/
SPBRG = ((_XTAL_FREQ/16)/Baud_rate) - 1;
BRGH = 1; // for high baud_rate
SYNC = 0; // Asynchronous
SPEN = 1; // Enable serial port pins
TXEN = 1; // enable transmission
CREN = 1; // enable reception
TX9 = 0; // 8-bit reception selected
RX9 = 0; // 8-bit reception mode selected
}
void UART_send_char(char c) //Function to send one byte of date to UART
{
while(!TXIF); // Wait till the transmitter register becomes empty
TXREG = c; //load the char to be transmitted into transmit reg
}
// Sends null-terminated ASCII string
void UART_send_string(char* p)
{
char c;
while((c = *p) != '\0')
{
UART_send_char(c);
p++;
}
}
void main(void)
{
Initialize_UART(); //Initialize UART module
char byte = 0x41;
}