p1ng54
New Member
Hi I am using pic18f452 and I am trying to get it to communicate with laptop through RS-232. I used hex file from mikroC built in library code and tried burning it using genius g540 it didnt work I got HIGH(Logic 1) output on several pins I didnt code to and LOW(Logic 0) on which I coded to get HIGH. then I used mplab code and after several tries I got my desired output (all pins HIGH) except for the port E which I did program as HIGH. Below is my mplab code
C:
#include <p18f452.h>
//Global variables
char word=1;
// main code
void main()
{
int i;
ADCON0=0;
TRISA=0;
TRISB=0;
TRISC=0;
TRISD=0;
TRISE=0;
// TRISCbits.TRISC6=0;
// TRISCbits.TRISC7=1;
// TXSTA=0x20; //configuring TX reg
// SPBRG=15; //Setting BAUD Rate
// TXSTAbits.TXEN=1; //TX EN
// RCSTAbits.SPEN=1; //Serial port EN
// RCSTAbits.CREN=1; //Continous recieve en
PORTA=0xFF;
PORTB=0xFF;
PORTC=0xFF;
PORTD=0xFF;
PORTE=0xFF;
//while(1)
//{
// while(PIR1bits.RCIF==0);
// word=RCREG;
// PORTB=word;
// word = word + 0x30;
// TXREG=word;
// word = word - 0x30;
// PIR1bits.RCIF=0;
//
//}
}
Last edited by a moderator: