Re: Wireless - switchless kernal mod

From: Mike Naberezny <mike_at_naberezny.com>
Date: Tue, 3 Apr 2018 09:44:39 -0700
Message-ID: <e9752081-e6d4-9c98-2cb7-73d69a61c8d5@naberezny.com>
On 4/3/18 6:42 AM, Nejat Dilek wrote:
> Unfortunately I did a bad selection of choosing the pins for my
> prototype design. For the Attiny85 most versatile pin for interrupt
> handling seems to be PB2 pin which on my design tied to Eprom SEL2
> line. Pin change interrupts are available on all pins but they trigger
> on both edges of a pulse which would be tricky.

I used an AVR pin change interrupt to detect an edge on a past project.  The 
code was in assembly.  The AVR has a large number of working registers so I 
reserved one of them for the pin change interrupt service routine.  The very 
first instruction of the ISR, before preserving registers or anything else, 
was to read the port into that dedicated register.  This was to capture the 
state of the pin as close in time as possible to when the edge occurred.  The 
ISR would then compare the value to detect the edge and either continue or 
bail out.

Source code:
https://github.com/mnaberez/vwradio/blob/b06c3a95f9b345dc4330cc3a8751b3f6244829ba/avr_volume/firmware/m62419fp_spi.asm#L50-L61

This is only an approximation of edge detection.  Several processor cycles 
will occur between the edge and that first instruction of the ISR capturing 
the port value.  The pin may change state again during that time.  In my 
project, the signal I was sampling was slow enough that this was acceptable.

Regards,
Mike

-- 
Mike Naberezny (mike@naberezny.com) http://6502.org
Received on 2018-04-03 19:00:02

Archive generated by hypermail 2.2.0.