Answer:
see explaination
Explanation:
1.) Each time the main program execution starts at address 0000 - Reset Vector. The address 0004 is “reserved” for the “interrupt service routine” (ISR).
ORG 0x000 ; processor reset vector
goto main ; go to beginning of main program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
.
.
RETFIE
main
3.) Push button switch is connected to the first bit of PORT B (RB0) which is configured as an input pin. When the switch is pressed this pin RB0 will be grounded. The LED is connected to the first bit of PORT B (RA0)
4.) Push button switch is connected to the first bit of PORT B (RB0) which is configured as an input pin. When the switch is pressed this pin RB0 will be grounded. The LED is connected to the first bit of PORT B (RA0)
5.) Push button switch is connected to the first bit of PORT B (RB0) which is configured as an input pin. When the switch is pressed this pin RB0 will be grounded. The LED is connected to the first bit of PORT B (RA0)
#include <stdio.h>
#include <stdlib.h>
#define _XTAL_FREQ 800000//Declare internal OSC Freq as 8MHz
#include <xc.h>
#include<pic.h>
CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & CCPMX_RB0 & CP_OFF);
CONFIG(FCMEN_ON & IESO_ON);
unsigned int count=0;
main()
{
TRISA=0;//Sets all ports on A to be outputs
TRISB=1;//Sets all ports on B to be inputs
for(;;){
if(PORTBbits.RB0==1){//When the button is pressed the LED is off
PORTAbits.RA1 =0;
count=count+1;
}
else {
PORTAbits.RA1=1;
count = count +1;
}
if (count > 6){//if count =6 i.e 6 times button presses the RED LED turns on
PORTAbits.RA0=1;
}
else{
PORTAbits.RA0=0;
}
}
}
#include <stdio.h>
#include <stdlib.h>
#define _XTAL_FREQ 800000//Declare internal OSC Freq as 8MHz
#include <xc.h>
#include<pic.h>
CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & CCPMX_RB0 & CP_OFF);
CONFIG(FCMEN_ON & IESO_ON);
unsigned int count=0;
main()
{
TRISA=0;//Sets all ports on A to be outputs
TRISB=1;//Sets all ports on B to be inputs
for(;;){
if(PORTBbits.RB0==1){//When the button is pressed the LED is off
PORTAbits.RA1 =0;
count=count+1;
}
else {
PORTAbits.RA1=1;
count = count +1;
}
if (count > 8){//if count =8 i.e 8 times button presses the RED LED turns on
PORTAbits.RA0=1;
}
else{
PORTAbits.RA0=0;
}
}
}
#include <stdio.h>
#include <stdlib.h>
#define _XTAL_FREQ 800000//Declare internal OSC Freq as 8MHz
#include <xc.h>
#include<pic.h>
CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & CCPMX_RB0 & CP_OFF);
CONFIG(FCMEN_ON & IESO_ON);
unsigned int count=0;
main()
{
TRISA=0;//Sets all ports on A to be outputs
TRISB=1;//Sets all ports on B to be inputs
for(;;){
if(PORTBbits.RB0==1){//When the button is pressed the LED is off
PORTAbits.RA1 =0;
count=count+1;
}
else {
PORTAbits.RA1=1;
count = count +1;
}
if (count > 10){//if count =10 i.e 10 times button presses the RED LED turns on
PORTAbits.RA0=1;
}
else{
PORTAbits.RA0=0;
}
}
}