INTernal
OSCillator... sounds like external oscillator?
Remove this #define OSCCON nonsense.
OSCCON is a register in the RAM.
It is modified during program execution. (in your main function)
OSCCON has nothing to do with the FOSC settings in the config register Susan told you to have a look at!
Except that frequency selection in OSCCON only makes sense if INTOSC is selected in FOSC
May be you think the __delay() function is not working,
because in the beginning you had only one delay?
The time PORTD was high is only some microseconds and you cant see any blinking!
If you have only one delay then you need to toggle the PORT after each time the delay elapsed.
- Code: Select all
...
#define _XTAL_FREQ (4000000UL)
void main(void)
{
TRISD = 0x00;
while(1){
__delay_ms(100);
PORTD ^= 0xFF; // <<-- toggle the port (^=)
}
}
´
You possibly want to have a look at how to run a program in debug mode.
It may help you to understand whats going on.
SIMULATOR ->
https://microchipdeveloper.com/tls0101:lab2PICKIT4 ->
https://microchipdeveloper.com/tls0101:lab3You can use your own code. No need to get the example shown in the lessons!