amitaiwe
Member level 3
- Joined
- Feb 19, 2014
- Messages
- 57
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Activity points
- 547
Hi,
All communications like USART, SPI, I2C need exacting timings to be able to work with the devices they connect to.
Your best way forward is to look for a Pic project that does the detecting but from a standard port pin/s so allowing you to use a proper crystal as the main oscillator which then allows you to run the program code and communications properly.
Thanks again for all the Patience,
I don't intend changing or interfering with the crystal oscillation .
What I want to do is as follows:
Using the clock out pin of the pic as the clock for the SPI protocol and using the same
output to connect to a inductor and from there to the SPI receiver pin and then compare
to the previous result.
The reason i want to use a SPI protocol is because as I see it oscillating a freq.
via a PIO is implemented by clearing and setting a single bit and in order to be able
to see changes in the freq. a register result is need and not a bit change.
I'm attaching a code which I thought of using in the first place for implementing the idea
and I didn't see any way for the part of getting the change of frequency information.
I hope I'm clear enough, Amitai
Code:
LIST P=PIC16F877
include <P16f877.inc>
org 0x00
reset: goto start
org 0x04
start: bcf STATUS, RP1
bsf STATUS, RP0 ;bank 1
;------------------------------------------------------------------------------
movlw 0xFE
movwf TRISC ;portC: RC0-Output
;------------------------------------------------------------------------------
bcf STATUS, RP0 ;bank 0
LOOP: bsf PORTC,0 ;RC0 = '1'
call DELAY_1m
bcf PORTC,0 ;RC0 = '0'
call DELAY_1m
goto LOOP
;------------------------------------------------------------------------------
DELAY_1m:
movlw 0x2f ; N1 = 47
movwf 0x30
cont2: movlw 0x10 ; N2 = 16
movwf 0x31
cont1: decfsz 0x31,1
goto cont1
decfsz 0x30,1
goto cont2
return
;------------------------------------------------------------------------------
end
- - - Updated - - -
I have now also a PIC16f88 which has an internal osc. and using it
I can be sure that I don't change somehow the pic's routine freq. , and it
seems to have the same functions which I need as the PIC16f877
Amitai