Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18f452

Status
Not open for further replies.

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:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top