list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO1, WDT = OFF, LVP = OFF, DEBUG = ON
Axis_Port Equ PORTA ; Set Axis_Port to Equal PortB
Axis_Tris Equ TRISA ; Set Axis_Tris to Equal TrisB
X_Axis Equ 1 ; Set X_Axis to Equal 1
Y_Axis Equ 2 ; Set Y_Axis to Equal 4
org 0x0000 ; Beggining of Program
Init
movlw 0x72 ; 8MHz clock select
movwf OSCCON ; Move to OSCILLATOR CONTROL REGISTER
clrf Axis_Tris ; Set All Output
bsf Axis_Tris, X_Axis ; Set Axis_Tris.X_Axis as input
bsf Axis_Tris, Y_Axis ; Set Axis_Tris.Y_Axis as input
clrf ADCON1
movlw b'00000101' ; Enable A/D, AN1
movwf ADCON0
Main
bsf ADCON0,GO ; Start A/D conversion
AD_Loop
btfsc ADCON0,DONE ; Check if done. If not goto adloop else skip loop
goto AD_Loop
goto Main ; Loop back to main
End
Or should i be looking into the CCP Module?
Yes i have seen that but the thing is that they dont specify like how to read the pulses... i think i read its like 100hz which would be about 200 cycles @ 8mhz but how in the world would i read it?
Do i need to use the timer to capture it ? What signifies like a start bit? These are things i am yet to get info on...
Now you see why I got one with analog out!?!I have a Accelerometer Module with a MX2125 Chip on board and it supposed to pulse out like a PWM but instead of PWM i was woundering with a multimeter i read 2.5v on a level surface can i use a A/D Conversion to get the values instead?
hi atom,on hand i own 1 LM339 and 1 LM741 Would any of those work for this?
1. Make sure the timer is off and clear it. Set the CCP module to watch for a rising edge first. Clear the flag CCPxIF and then wait for it to be set again, signifying a rising edge.
hi,i have not tried nothing yet just writing all suggestions .... Also at the moment i am trying to learn how to use this timer thing...
I know how to do the second half of that sentence but how do i do whats in BOLD Above?
Also just to make sure ...would i do like a BTFSS on CCP1IF ... and then jump to start if it is clear(0) and if set(1) then clear it and continue to look for falling edge?
bcf T3CON, TMR3ON
clrf TMR3L
clrf TMR3H ;timer3 cleared and off
bcf PIR1, CCP1IF ;clear the flag
Loop1 btfss PIR1, CCP1IF ;wait for the rising edge
goto Loop1
bsf T3CON, TMR3ON ;then start the timer
bcf PIR1, CCP1IF ;clear the flag
Loop2 btfss PIR1, CCP1IF ;wait for the falling edge
goto Loop2
bcf PIR1, CCP1IF
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO1, WDT = OFF, LVP = OFF, DEBUG = ON
Axis_Port Equ PORTB ; Set Axis_Port to Equal PortB
Axis_Tris Equ TRISB ; Set Axis_Tris to Equal TrisB
X_Axis Equ 3 ; Set X_Axis to Equal 3
org 0x0000 ; Beggining of Program
Init
movlw 0x62 ; 8MHz clock select
movwf OSCCON ; Move to OSCILLATOR CONTROL REGISTER
clrf Axis_Tris ; Set All Output
bsf Axis_Tris, X_Axis ; Set Axis_Tris.X_Axis as input
Main
bcf T3CON, TMR3ON
clrf TMR3L
clrf TMR3H ;timer3 cleared and off
movlw 0x05 ; Rising Edge Selection
movwf CCP1CON
bcf PIR1, CCP1IF ;clear the flag
Loop1
btfss PIR1, CCP1IF ;wait for the rising edge
goto Loop1
bsf T3CON, TMR3ON ;then start the timer
bcf PIR1, CCP1IF ;clear the flag
movlw 0x04 ;Falling Edge Selection
movwf CCP1CON
Loop2
btfss PIR1, CCP1IF ;wait for the falling edge
goto Loop2
bcf PIR1, CCP1IF
goto Main ; Loop back to main
End
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO1, WDT = OFF, LVP = OFF, DEBUG = ON
Axis_Port Equ PORTB ; Set Axis_Port to Equal PortB
Axis_Tris Equ TRISB ; Set Axis_Tris to Equal TrisB
X_Axis Equ 3 ; Set X_Axis to Equal 3
org 0x0000 ; Beggining of Program
Init
movlw 0x72 ; 8MHz clock select
movwf OSCCON ; Move to OSCILLATOR CONTROL REGISTER
clrf Axis_Tris ; Set All Output
bsf Axis_Tris, X_Axis ; Set Axis_Tris.X_Axis as input
movlw b'10111100'
movwf T3CON
Main
bcf T3CON, TMR3ON
clrf TMR3L
clrf TMR3H ;timer3 cleared and off
movlw 0x05 ; Rising Edge Selection
movwf CCP1CON
bcf PIR1, CCP1IF ;clear the flag
Loop1
btfss PIR1, CCP1IF ;wait for the rising edge
goto Loop1
bsf T3CON, TMR3ON ;then start the timer
bcf PIR1, CCP1IF ;clear the flag
movlw 0x04 ;Falling Edge Selection
movwf CCP1CON
Loop2
btfss PIR1, CCP1IF ;wait for the falling edge
goto Loop2
bcf T3CON, TMR3ON ;then start the timer
bcf PIR1, CCP1IF
goto Main ; Loop back to main
End
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?