Advertisement
czaru34

wbudowanelab3zad7

Apr 6th, 2020
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <targets/AT91SAM7.h>
  2. #include "PCF8833U8_lcd.h"
  3.  
  4. void adcInit() {
  5.   ADC_CR = 1 << 0;
  6.   ADC_CHER = 1 << 6;
  7.   ADC_IDR = 0xFFFFF;
  8.   ADC_MR = (23 << ADC_MR_PRESCAL_BIT) |
  9.            (2 << ADC_MR_STARTUP_BIT) |
  10.            (1 << ADC_MR_SHTIM_BIT) |
  11.            (1 << ADC_MR_LOWRES);
  12.   ADC_CR_START;
  13. }
  14.  
  15. int main() {
  16.   adcInit();
  17.   InitLCD();
  18.  
  19.   while(1)
  20.     if(ADC_SR & ADC_SR_EOC6)
  21.       if (ADC_CDR6 < 126) PIOB_CODR = 1 << 20;
  22.       else PIOB_SODR = 1 << 20;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement