Hi,
I am trying to send data over RS232. The analouge signal is coming from a temperature sensor (LM-35) and is being dizitised by PICC18F4520. Then it should send the data via RS232 port to Hyper Terminal. But I can't see any thing. Is any thing wrong with my codes.
Thanks in advance
P:S: I am using a seven segment as well, for the privious effort - so the codes remained.
I am trying to send data over RS232. The analouge signal is coming from a temperature sensor (LM-35) and is being dizitised by PICC18F4520. Then it should send the data via RS232 port to Hyper Terminal. But I can't see any thing. Is any thing wrong with my codes.
Thanks in advance
P:S: I am using a seven segment as well, for the privious effort - so the codes remained.
#include <p18f4520.h>
#include <delays.h>
#include <usart.h>
#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config PBADEN = OFF
#pragma config DEBUG = ON
const char LED[10] = {
0b01111111, /*0*/
0b00001101, /*1*/
0b10110111, /*2*/
0b10011111, /*3*/
0b11001101, /*4*/
0b11011011, /*5*/
0b11111011, /*6*/
0b00001111, /*7*/
0b11111111, /*8*/
0b11001111, /*9*/
};
void main (void)
{
unsigned short result = 0;
unsigned char temp;
unsigned char units;
unsigned char tens;
unsigned char nunits;
unsigned char ntens;
TRISC = 0b11000000;
TRISD = 0b00000000;
ADCON0 = 0b00000000;
ADCON1 = 0b00001110;
ADCON2 = 0b10001100;
ADCON0bits.ADON = 1;
OpenUSART(USART_TX_INT_OFF & USART_BRGH_HIGH & USART_ASYNCH_MODE & USART_EIGHT_BIT,25);
TXSTA = 0b00100100; //8bit-trsnmit disable-high baud rt-asynchronous
RCSTAbits.CREN = 0; //Disable Reciever.
BAUDCON = 0b00000000; //8bit
while (1)
{
RCSTAbits.SPEN = 1; //Serial Port Enable - TX/DT
ADCON0bits.GO = 1;
while(ADCON0bits.GO);
result = ADRESH;
result = result << 8;
result = result + ADRESL;
temp = (result*0.4882815 + 2);
units = temp%10;
tens = (temp/10)%10;
PORTC = ~LED[units];
PORTD = ~LED[tens];
TXREG = temp;
PORTCbits.RC6 = TXREG;
}
}