Hi all,

Thank you for a great forum....i mean REALLY great!

I don't post very often, usually only when i need help..i know it's a little selfish but....

any way! i am designing a controller for a plastic film winding machine,

all my code works very well, i am using darrel's brilliant dt_ints for ccp1 ,portb change, serial usart and tmr0.

ok, now for my "issue" :
i am using ccp2 for hpwm and also 2 off sofware pwm's

when i have high rpm's you can hear the software rpm signal being "coloured" by the ccp1 interrupts, it is not a problem as the pwm works very well, it is more of a niggle than anything.


i would like to include the rpm calculation in the ccp1 interrupt but there is no way i can at the moment.

i know dt_ints saves data before and restores data after the interrupt, would it be any quicker to use assembly ?..well i suppose it would but i don't know where to start with interrupts in assembly


i already run the tacho through a flip flop to reduce the freq and due to responce times i don't really want to capture *4 or 16 rising edges.

if any one could start me off with an assembly call to a ccp1 int handler and how to return from it i would be really gratefull!


thanks in advance and p.s. here are my code snippetts..(please don't laugh at my code,,, i am still learning!)









'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 1/21/2010 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
''device=18f2620

osccon.0=1 ' internal osc
osccon.4=1 ' int oscillator
osccon.5=1 ' scaling for
osccon.6=1 ' 8 MHZ

DEFINE ADC_BITS 8 'Set number of bits in result
DEFINE ADC_CLOCK 3 'Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 5 'Set sampling time in microseconds

CCP1CON = %00000100 'capture timer0 every falling edge portc.2

t0con.0=0 'timer0 on
t0con.1=1
t0con.2=0
t0con.3=0
t0con.5=0
t0con.6=0
t0con.7=1
'yadda yadda yadda! etc






ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?

int_handler rx_int, _read_usart, pbp, yes
INT_Handler CCP1_INT, _get_pulsewidth, PBP, yes
int_handler int0_int, _feed_request, pbp, yes
int_handler int1_int, _heat_request, pbp, yes
int_handler int2_int, _get_position, pbp, yes
int_handler tmr0_int, _no_pulse, pbp, yes


endm
INT_CREATE ; Creates the interrupt processor
ENDASM















'------------------------------------------[tacho pulse interrupt routine]---------------------------------------------------
get_pulsewidth:

t1con.7=0 'stop the timer
pulsewidth.lowbyte=tmr0l 'get the low byte timer result
pulsewidth.highbyte=tmr0h 'get the high byte timer result
tmr0h=0 'zero the
tmr0l=0 'timer
pulse_ok=1
t1con.7=1 'restart the timer

@ int_return

'--------------------------------------[no valid rpm signal, timer1 overflow]-----------------------------------------------
no_pulse:
pulse_ok=0
rpm=0
@ int_return