Advertisement
czaru34

wbudowanelab3zad8

Apr 6th, 2020
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <targets/AT91SAM7.h>
  2. #include <stdlib.h>
  3. #include "PCF8833U8_lcd.h"
  4.  
  5. void adcInit() {
  6.   ADC_CR = 1 << 0;
  7.   ADC_CHER = 1 << 5;
  8.   ADC_IDR = 0xFFFFF;
  9.   ADC_MR = (23 << ADC_MR_PRESCAL_BIT) |
  10.            (2 << ADC_MR_STARTUP_BIT) |
  11.            (1 << ADC_MR_SHTIM_BIT);
  12.   ADC_CR_START;
  13. }
  14.  
  15. int main() {
  16.   adcInit();
  17.   InitLCD();
  18.  
  19.   char buffer[10];
  20.  
  21.   while(1)
  22.     if(ADC_SR & ADC_SR_EOC5) {
  23.       int termVoltage = ADC_CDR5;
  24.       itoa(termVoltage, buffer, 10);
  25.       LCDPutStr(buffer, 20, 20, LARGE, WHITE, BLACK);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement