W65c265 - PWM - help

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
swiety
Posts: 10
Joined: 04 Jun 2003
Location: Poland
Contact:

W65c265 - PWM - help

Post by swiety »

I have a problem at my new prototype build on w65c265. My project use this input for counting and time checking beetwen a pluses form crank sensor on a engine.
This routine work correctly at older project based on 6502 and 8520 CIA (from Amiga 500).
I read a datasheet from WDC , but i still dont know how Timer 7 working.
If i understand correctly - a defined edge on PWM pin generating interrupt - this work ok. A timer7 counters at this moment are latching at T7CL and T7CH.
But when i reading this registers my routine work verry strange.
Maybe i must read T7Cl first, maybe write to eifr first, maybe ........ i dont know


Now is some part of my code:

irpe62 pha

; copy timer7 latched data into memory

lda t7ch
sta bak_todmid
lda t7cl
sta bak_todlo

lda pd4 ; for checking interrupt response
eor #%0010000 ; at every pulse change bit at PD4
sta pd4

; $ffff - TIMER7 value

sec
lda #$ff
sbc bak_todlo
sta bak_todlo

lda #$ff
sbc bak_todmid
sta bak_todmid

; calculate tod-oldtod/2

lda bak_todlo
sec
sbc old_todlo

lda bak_todmid
sbc old_todmid

bcs next_tooth

; obsluga zabka indexowego

lda pd4 ;
and #%11101111 ;
sta pd4 ;

jmp end_tooth ; kasuj poprzedni licznik!



next_tooth

lda pd4
ora #%00010000
sta pd4


lda #$ff ; zliczaj od nowa - czyli $ffff
sta T7CL
sta T7CH


end_tooth

lda bak_todmid
lsr a
sta old_todmid

lda bak_todlo
ror a
sta old_todlo

no_flag


lda #%00001000
sta eifr
pla
rti

Please help me, i spent a 4 days for checking this routine and i dont know why i cant read data from timer correctly ?
kc5tja
Posts: 1706
Joined: 04 Jan 2003

Post by kc5tja »

I personally don't have experience with this chip. However, the person to ask would be "NightmareTony", since he is the most recent person on this forum I'm aware of to use the 65C134, the 8-bit version of the 65C265. He probably would be able to help out.
Post Reply