C - Program recording PIC 18F4550 via USB

Asked

Viewed 185 times

1

At first, I’m a layman when it comes to programming. Because of this, I am developing fast and easy programs to improve my knowledge gradually..

I have a development board of a PIC18F4550, with LEDS on RB pins, some on RD and RC. The buttons are on RE pins.

Placa de desenvolvimento

Bootloader has already been recorded on this PIC, so I’m using the USB (which is at the bottom of the board) to write to the PC. When I run a code (I’m using MPLAB X), I load . Hex on recorder, and when arriving at 99%, the recorder program simply stops responding, and closes...

Print do programa travado

Is there any procedure that is missing for recording the program? Detail, when I record a program done by a college professor, it works normally. And I couldn’t find any part of the program that changes the recording configuration, just the same programming logic...

Below is the code I wrote. The clock I’m using is 48 Mhz, and the external oscillator is 20 Mhz.

I hope I made myself clear. A hug!

#include <xc.h>
#include "config.h"

void configura_uc()
{
    //Configura botão do PORTE como entrada e LEDS como saída
    TRISB=0xFF;
    TRISC=0xFF;
    TRISD=0xFF;
    TRISE=0x00;
}
void main(void) {
    configura_uc();
    while (1)
    {
        if (PORTEbits.RE0 = 1)
        {
            PORTBbits.RB7 = 1;
            PORTBbits.RB6 = 1;
            PORTBbits.RB5 = 1;
            PORTBbits.RB4 = 1;
        }
        if (PORTEbits.RE1 = 1)
        {
            PORTBbits.RB3 = 1;
            PORTBbits.RB2 = 1;
            PORTBbits.RB1 = 1;
            PORTBbits.RB0 = 1;
        }
        if (PORTEbits.RE2 = 1)
        {
            PORTDbits.RD7 = 1;
            PORTDbits.RD6 = 1;
            PORTDbits.RD5 = 1;
            PORTDbits.RD4 = 1;   
        }
    }
    return;
}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.