Reputation: 1163
I have this code for the MCU (pic18f4580) :
#include <pic18F4580.h>
#pragma config OSC=HS
#pragma config LVP=OFF
#pragma config PBADEN=OFF
#pragma config WDT=OFF
#pragma config MCLRE=ON
#define _XTAL_FREQ 4000000
void main(void) {
TRISB = 0x00;
while(1) {
PORTB = 0xFF;
//_delay_ms(500);
}
return;
}
I have generated the hex file with MPLAPX and compiler XC8
This is the schemata I made in Proteus, but the LED won't turn on:
Upvotes: 1
Views: 181
Reputation: 31
There is 2 problem
1)In proteus you have to connect power to "VPP" pin (pin number 1 in the microcontroller at the bottom right).
2)In code PORTB used to read inputs on pins(reads the levels on the pins of the device), instead you have to use LATB register (output latch) to control pin as high or low.
Remove
PORTB = 0xFF;
TO
LATB = 0xFF;
and if you need to toggle it every 500 milliseconds
LATB ^= 0xFF;
Upvotes: 0
Reputation: 4288
You had to switch the port RB0
to digital, on default it is an analog port.
ADCON1 = 0x01;
See section 20.0 in the datasheet.
Upvotes: 0