Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#include <htc.h>
__CONFIG( BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS & CP_OFF );
#define _XTAL_FREQ 20000000 //; <--- This semi colon shouldn't be here
void main()
{
TRISC = 0 ;
while(1){
PORTC=0XFF;
__delay_ms(500);
PORTC=0X00;
__delay_ms(500);
}
}
DELAY MOVLW 0X01 ; 1 inst cycle
MOVWF count1 ; 1 inst cycle 2
delay MOVLW 0X02 ; 1 inst cycle 2+
MOVWF counta ; 1 inst cycle
delay_0
DECFSZ counta,f ; 2 inst cycle 2+2
GOTO delay_0 ; 2 inst cycle 2+
DECFSZ count1,f ; 2 inst cycle 2+
GOTO delay ; 2 inst cycle 2+
RETURN ; 2 inst cycle 2
yes, it is right it is taking 1 cyle on incorrect
Code:Delay ;19 cycles movlw 0x06 movwf d1 Delay_0 decfsz d1, f goto Delay_0 NOP ;added
Internally, the program counter (PC) is incremented
every Q1, and the instruction is fetched from the program memory and latched into the
instruction register in Q4.
An “Instruction Cycle” consists of four Q cycles (Q1, Q2, Q3, and Q4). Fetch takes one instruction
cycle while decode and execute takes another instruction cycle. However, due to Pipelining, each
instruction effectively executes in one cycle. If an instruction causes the program counter to
change (e.g. GOTO) then an extra cycle is required to complete the instruction (Example 4-1).
C:#include <htc.h> __CONFIG( BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS & CP_OFF ); #define _XTAL_FREQ 20000000 //; <--- This semi colon shouldn't be here void main() { TRISC = 0 ; while(1){ PORTC=0XFF; __delay_ms(500); PORTC=0X00; __delay_ms(500); } }
Simples!!!