logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

Działanie przetwornika ADC w Atmega: konwersja w tle czy zatrzymuje program główny?

Osator90 07 Mar 2023 21:55 351 2
REKLAMA
  • #1 20475062
    Osator90
    Poziom 10  
    Dzień dobry.
    Mam pytanko odnośnie działania przetwornika ADC w mikrokontrolerach Atmega.

    Czy w momencie uruchomienia konwersji czy to w pojedynczym pomiarze czy też free running mode, przetwornik w naszym mikrokontrolerze działa sobie "w tle" i nie zakłóca działania programu głównego.
    Czy raczej uruchomienie pomiaru ADC zatrzymuje program główny, dokonuje konwersji i wraca do programu głównego ?
  • REKLAMA
  • #2 20475098
    tmf
    VIP Zasłużony dla elektroda
    Osator90 napisał:
    Czy raczej uruchomienie pomiaru ADC zatrzymuje program główny, dokonuje konwersji i wraca do programu głównego ?

    Wszystkie ukłądy peryferyjne działają niezależnie. Zresztą, gdyby np. ADC wstrzymywał pracę CPU, to nie miałyby sensu bity rejestru stanu ADC informujące o zakończeniu konwersji :)
  • #3 20475162
    gps79
    Poziom 35  
    Standardowo ADC nie zakłóca działania pozostałych komponentów w Atmedze. Program działa poprawnie podczas konwersji ADC.
    Istnieje jednak mechanizm zmniejszania zakłóceń podczas konwersji ADC, dzięki któremu można uzyskać dokładniejsze odczyty. Możesz przeczytać o tym w datasheet mikrokontrolera,
    np. tutaj:
    https://ww1.microchip.com/downloads/en/Device...ive-Microcontrollers-ATmega328P_Datasheet.pdf
    Rozdział 23.6 ADC Noise Canceler
    The ADC features a noise canceler that enables conversion during sleep mode to reduce noise induced from the CPU core
    and other I/O peripherals. The noise canceler can be used with ADC noise reduction and idle mode. To make use of this
    feature, the following procedure should be used:
    a. Make sure that the ADC is enabled and is not busy converting. Single Conversion mode must be selected and the
    ADC conversion complete interrupt must be enabled.
    b. Enter ADC Noise Reduction mode (or Idle mode). The ADC will start a conversion once the CPU has been halted.
    c. If no other interrupts occur before the ADC conversion completes, the ADC interrupt will wake up the CPU and
    execute the ADC Conversion Complete interrupt routine. If another interrupt wakes up the CPU before the ADC
    conversion is complete, that interrupt will be executed, and an ADC Conversion Complete interrupt request will be
    generated when the ADC conversion completes. The CPU will remain in active mode until a new sleep command
    is executed.
REKLAMA