Kanał - ATNEL tech-forum
Wszystkie działy
Najnowsze wątki



Teraz jest 9 mar 2025, o 23:05


Strefa czasowa: UTC + 1





Utwórz nowy wątek Odpowiedz w wątku  [ Posty: 2 ] 
Autor Wiadomość
PostNapisane: 15 lut 2017, o 07:53 
Offline
Nowy

Dołączył(a): 15 lut 2017
Posty: 5
Pomógł: 0

I'm developing a small logic analyzer with 7 inputs. My target device is an ATmega168 with a 20MHz clock rate. To detect logic changes I use pin change interrupts. Now I'm trying to find out the lowest sample rate I can detected these pin changes. I determined a value of minimum 5.6 µs (178.5 kHz). Every signal below this rate I can't capture properly.
My code is written in C (avr-gcc). My routine looks like:
Kod:
ISR()
{
    pinc = PINC; // char
    timestamp_ll = TCNT1L; // char
    timestamp_lh = TCNT1H; // char
    timestamp_h = timerh; // 2 byte integer
    stack_counter++;
}

My captured signal change is located at pinc. To localize it I have a 4 byte long timestamp value.
In the datasheet I read the interrupt service routine takes 5 clocks to jump in and 5 clocks to return to the main procedure. I'm assuming each command in my ISR() is taking 1 clock to be executed; So in sum there should be an overhead of 5 + 5 + 5 = 15clocks. The duration of one clock should be according to the clock rate of 20MHz 1/20000000 = 0.00000005 = 50 ns. The total overhead in seconds should be then: 15 * 50 ns = 750 ns = 0.75 µs. Now I don't understand why I can't capture anything below 5.6 µs. Can anyone explain what's going on?



Góra
 Zobacz profil  
cytowanie selektywne  Cytuj  
PostNapisane: 15 lut 2017, o 08:12 
Offline
Moderator
Avatar użytkownika

Dołączył(a): 03 paź 2011
Posty: 27362
Lokalizacja: Szczecin
Pomógł: 1043

Do you have checked how this interrupt routine looks in *.lss file ? (In assembler ?) I advice to check it and I advice to check it and count how many clock ticks there are used.

Remember that ISR have necessary begin with push's and end with pop's

_________________
zapraszam na blog: http://www.mirekk36.blogspot.com (mój nick Skype: mirekk36 ) [ obejrzyj Kurs EAGLE ] [ mój kanał YT TV www.youtube.com/mirekk36 ]



Góra
 Zobacz profil  
cytowanie selektywne  Cytuj  
Wyświetl posty nie starsze niż:  Sortuj wg  
Utwórz nowy wątek Odpowiedz w wątku  [ Posty: 2 ] 

Strefa czasowa: UTC + 1


Kto przegląda forum

Użytkownicy przeglądający ten dział: Brak zidentyfikowanych użytkowników i 3 gości


Nie możesz rozpoczynać nowych wątków
Nie możesz odpowiadać w wątkach
Nie możesz edytować swoich postów
Nie możesz usuwać swoich postów
Nie możesz dodawać załączników

Szukaj:
Skocz do:  
Sitemap
Technologię dostarcza phpBB® Forum Software © phpBB Group phpBB3.PL
phpBB SEO