Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include <string.h>
  4. #include <targets\AT91SAM7.h>
  5. #include <stdbool.h>
  6. #include "pcf8833u8_lcd.h"
  7.  
  8.  
  9. void wait(int ms){
  10.  
  11.   volatile int i,j;
  12.  
  13.   for(i = 0; i < ms; i++){
  14.     for(j = 0; j <= 3000; j++){
  15.     __asm__("NOP");
  16.     }
  17.   }
  18. }
  19.  
  20.  
  21. int main(void){
  22.  
  23.   char z[4];
  24.   int a;
  25.   InitLCD();  // inicjalizacja ekranu
  26.   SetContrast(5); // ustawienie kontrastu
  27.   Backlight(BL_ON);
  28.   LCDClearScreen();  // czyszczenie ekranu
  29.  
  30.   PMC_PCER = 1 << 17;
  31.   ADC_CR = 1 << 0;
  32.  
  33.   ADC_CHER = 1 << 6;
  34.   ADC_MR = (23 << ADC_MR_PRESCAL_BIT | 1  << ADC_MR_SHTIM_BIT | 2  << ADC_MR_STARTUP_BIT);
  35.   ADC_CR = 1 << 1;
  36.  
  37.   while(1){
  38.  
  39.   while((ADC_SR & 1<<6) == 0){};
  40.   ADC_CR = 1 << 1;
  41.   a = ADC_CDR6;
  42.   itoa(a,z,10);
  43.   LCDPutStr(z,20,20,LARGE,WHITE,BLACK);
  44.   }
  45.    
  46.    return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement