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.
;May2008 Atomsoft
;Polling Accelerometer X and Y axis, using PORTA.7 and PORTA.6
;Timer1 holds the count equal to the time A.7 or A.6 are high
;The count is then transferred to XaxisH/L and YaxisH/L
;No LCD display on this version, so delays in the program.
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF, DEBUG = ON
XaxisH EQU 0x14
XaxisL EQU 0x15
YaxisH EQU 0x16
YaxisL EQU 0x17
org 0x00
goto Init ;go to start of main code
ORG 0x0008 ;High priority interrupt vector
retfie
ORG 0x0018 ;low priority interrupts
retfie
Init:
movlw 0x72 ; 8MHz clock select
movwf OSCCON
clrf TRISB ;PORTB all outs
[B] bsf TRISA, 6
bsf TRISA, 7[/B]
movlw 0x10 ;prescaler 1:2, 8MHz xtal, so 1uSec clock
movwf T1CON ;stop TMR1
Main:
Call Read_X
Call Read_Y
nop
;LCD subr goes here
goto Main
Read_X: ;if PORTA.7 already High, then wait for low
btfsc PORTA,7
return
WaitA7_Hi: ;wait for PORTA.7 to go high
btfss PORTA,7
goto WaitA7_Hi
bsf T1CON,TMR1ON ;start TMR1
WaitA7_Lo:
btfsc PORTA,7
goto WaitA7_Lo
bcf T1CON,TMR1ON ;stop TMR1
;
movf TMR1H,W ;read TMR1 and save count
movwf XaxisH
movf TMR1L,W
movwf XaxisL
clrf TMR1H
clrf TMR1L
return
Read_Y: ;if PORTA.6 already High, then wait for low
btfsc PORTA,6
return
WaitA6_Hi: ;wait for PORTA.6 to go high
btfss PORTA,6
goto WaitA6_Hi
bsf T1CON,TMR1ON
WaitA6_Lo:
btfsc PORTA,6
goto WaitA6_Lo
bcf T1CON,TMR1ON
;
movf TMR1H,W
movwf YaxisH
movf TMR1L,W
movwf YaxisL
clrf TMR1H
clrf TMR1L
return
End
;May2008 Atomsoft
;Polling Accelerometer X and Y axis, using PORTA.7 and PORTA.6
;Timer1 holds the count equal to the time A.7 or A.6 are high
;The count is then transferred to XaxisH/L and YaxisH/L
;No LCD display on this version, so delays in the program.
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF, DEBUG = ON
XaxisH EQU 0x14
XaxisL EQU 0x15
YaxisH EQU 0x16
YaxisL EQU 0x17
org 0x00
goto Init ;go to start of main code
ORG 0x0008 ;High priority interrupt vector
retfie
ORG 0x0018 ;low priority interrupts
retfie
Init:
movlw 0x72 ; 8MHz clock select
movwf OSCCON
clrf TRISB ;PORTB all outs
bsf TRISA, 6
bsf TRISA, 7
movlw 0x10 ;prescaler 1:2, 8MHz xtal, so 1uSec clock
movwf T1CON ;stop TMR1
Main:
Call Read_X
Call Read_Y
nop
goto Main
Read_X: ;if PORTA.7 already High, then wait for low
btfsc PORTA,7
return
WaitA7_Hi: ;wait for PORTA.7 to go high
btfss PORTA,7
goto WaitA7_Hi
bsf T1CON,TMR1ON ;start TMR1
WaitA7_Lo:
btfsc PORTA,7
goto WaitA7_Lo
bcf T1CON,TMR1ON ;stop TMR1
movf TMR1H,W ;read TMR1 and save count
movwf XaxisH
movf TMR1L,W
movwf XaxisL
clrf TMR1H
clrf TMR1L
return
Read_Y: ;if PORTA.6 already High, then wait for low
btfsc PORTA,6
return
WaitA6_Hi: ;wait for PORTA.6 to go high
btfss PORTA,6
goto WaitA6_Hi
bsf T1CON,TMR1ON
WaitA6_Lo:
btfsc PORTA,6
goto WaitA6_Lo
bcf T1CON,TMR1ON
movf TMR1H,W
movwf YaxisH
movf TMR1L,W
movwf YaxisL
clrf TMR1H
clrf TMR1L
return
End
Ubuntu Home Page | Ubuntuany links on this linux live disk futz?
Use the Add Symbol button to add a watch variable.
Thanks Atom.Futz forgot to tell you thanks and i love your site... (all the info and layout and all!)
I used to hard code all my sites. But then making changes and updates was kind of a pain so they tended to never get done. So this time I went with a CMS (Content Management System). Joomla 1.5. It's a bit buggy, but you soon discover what the bugs are and learn to work around them (not a big deal - just some editor quirks). It's free. Building templates for it is a chore, but luckily I like the stock one fine. Joomla makes updates and changes easy as it's built for blogging and that style of site.Ill be making a site pretty soon also. I know some HTML, PHP, MYSQL and stuff// so shouldn't be too hard![]()
How do you break an LCD?my last 2x16 lCD broke so i might have to order a new one
Not sure how but doesnt work so not going to kill myself checking it
EDIT:
Good luck with the balancer. Cant wait to see the results.
sure that would be awesome .. Thanks a bunch..Post away![]()
The value which I read on PIC is 4.8 time more then value which should be. My OSc is 20 MHZ i know, how can it react like a 96MHZ ? I have problems also with serial comm. despite I write DEFINE OSC 20...
Can someone help me ?