avr digital input

Thread Starter

Alasttt

Joined May 13, 2015
68
Hi,

I have a bit stream 100110, and I want to read this into the avr and store it in a variable. I going to use interuppts, however when you trigger on change its fine, but in my case some bits don't change and this means that the avr will skip those. So the avr will read 1010

Does anybody have any suggestions on how I could solve this ?

Cheers !
 

Papabravo

Joined Feb 24, 2006
21,225
From your verbal description I can't tell precisely what your expectations are. Normally with multiple digital inputs you sample all of them at the same time, regardless of whether they have changed recently or not. You can do this with a periodic timer, say every 20 milliseconds, or you can do it when any of the bits you are interested in change. So you take a sample by whatever means you deem appropriate and you look at one or more consecutive samples to see if the input has changed or remained the same. The process is known as debouncing and it normally applies to mechanical switches such as you might find on a keyboard or a game controller.

Here is an article by Jack Gansle, that you might enjoy.

http://www.embedded.com/electronics-blogs/break-points/4024981/My-favorite-software-debouncers
 

DickCappels

Joined Aug 21, 2008
10,171
What is generating the pattern?

Using the UART/USART in a popular way to get serial data into controllers. There is bit-banged serial port firmware available for controllers that don't have a UART/USATR.
 
Top