Its just for testing the circuit and its an assignmentWhat language?
Is this a school assignment or for personal use?
More details please?
John
... and I'm moving this to Homework.and its an assignment
I am using XC8 compiler and planning to programm with C and using ICD8 programmer and this is the programm i wrote for LED blinking.MPLAB is the IDE you work in. Which compiler are you planning to use? And with that question we want to know if you are planning to program in C or Assembly. Which programmer do you have? PICkit2 or PICkit3 or some other. What does you breadboard or schematic look like?
... and I'm moving this to Homework.![]()
// CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator: High-speed crystal/resonator on RA4/OSC2/CLKOUT and RA5/OSC1/CLKIN)
#pragma config WDTE = ON // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown-out Reset Selection bits (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#define _XTAL_FREQ = 15000000
void main(void)
{
TRISC4 = 0x00;
volatile unsigned int j = 0;
volatile int k = 0;
while(k < 10)
{
PORTCbits.RC4 = 0xFF;
for(j=0;j<64000;j++);
PORTCbits.RC4 = 0x00;
for(j=0;j<64000;j++);
k++;
}
while(1);//wait forever
}
Please can someone help with the code without using external switching on and offSo I'm guessing that what you need to do is change the state of the LED every time the interrupt is fired? In that case, switching it on, waiting and then switching it off again isn't really going to work. Instead you're going to need to have the code somehow alternate between states.
You've got two options, either you can check the current state of RC4 and change it accordingly or a tidier option would be to use some bitwise logic (research XOR if you don't already know how to use it) to alternate the state of the pin.
I would suggest the first thing you do is change your code so that instead of explicitly switching on and off, you instead alternate its state (go on, use bitwise logic. Get your head around it now and it'll serve you well in the future).
What do you mean by "external switching on and off"? I didn't see that in any posts? If you explain what you mean by this, I could better answer your question.Please can someone help with the code without using external switching on and off