Advertisement
Guest User

Untitled

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