1. What is radix?
2. How do i know my processor frequency? is it 4 MHZ or what not?
banksel PCON ;switch to bank 1
bsf PCON,3 ;set internal oscillator for 4MHz
banksel PCON ;switch to bank 1
bcf PCON,3 ;set internal oscillator for 37kHz
3. I read where you calculate your delay from your processor frequency, how do i do that?
Delay_1s
movlw 255 ;Pre-load delay counters with starting decriment value. Value 255 is the highest value you can
movwf Delay1 ;use on 8 bit processors. Decimal 255 can be noted as 0xFF or b'11111111'. For long delays, use
movwf Delay2 ;a nested delay loop as illustrated here.
movlw 0x05
movwf Delay3
Wait
decfsz Delay, F
goto Wait
decfsz Delay2,F
goto Wait
decfsz Delay3,F
return
Delay1 EQU 0x20
Delay2 EQU 0x21
Delay3 EQU 0x22
cblock 0x20
Delay1
Delay2
Delay3
endc
4. I meant how to include my header file in the little box, it shows source file, header file, object file, library file and a few others. is the header file for p16f648a in my C drive?
2.You pick a crystal say 4 mhz divide that by 4 1000000 instructions per secIn arithmetic, the radix or base refers to the number b in an expression of the form bn. The number n is called the exponent and the expression is known formally as exponentiation of b by n or the exponential of n with base b. It is more commonly expressed as "the nth power of b", "b to the nth power" or "b to the power n".
#include <p16F648a.inc>
1.
2.You pick a crystal say 4 mhz divide that by 4 1000000 instructions per sec
__CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_OFF & _INTOSC_OSC_NOCLKOUT
It's still the same divide by 4 gives instructions per sec just have to set it in configure INTOSC
And seeing he had that right wasn't no need to bring that up
; Delay = 1 seconds
; Clock frequency = 4 MHz
; Actual delay = 1 seconds = 1000000 cycles
; Error = 0 %
cblock
d1
d2
d3
endc
;999997 cycles
movlw 0x08
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;3 cycles
goto $+1
nop
This is for a 4mhz clock
You can generate code from here
Code:; Delay = 1 seconds ; Clock frequency = 4 MHz ; Actual delay = 1 seconds = 1000000 cycles ; Error = 0 % cblock d1 d2 d3 endc ;999997 cycles movlw 0x08 movwf d1 movlw 0x2F movwf d2 movlw 0x03 movwf d3 Delay_0 decfsz d1, f goto $+2 decfsz d2, f goto $+2 decfsz d3, f goto Delay_0 ;3 cycles goto $+1 nop
; Delay = 1 seconds
; Clock frequency = 8 MHz
; Actual delay = 1 seconds = 2000000 cycles
; Error = 0 %
cblock
d1
d2
d3
endc
Delay
;1999996 cycles
movlw 0x11
movwf d1
movlw 0x5D
movwf d2
movlw 0x05
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;4 cycles (including call)
return