SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "uart.h"
  2. #include "adc.h"
  3. #include <util/delay.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #define VT_HI 255
  8. #define VT_LO 0
  9. #define VT_M 128
  10. int main(void)
  11. {   uint16_t bafarsaiz = 250;
  12.     //uint32_t r = 0;
  13.     //char buffer[30];
  14.     uint8_t bufferCh0[bafarsaiz];
  15.     uint8_t bufferCh1[bafarsaiz];
  16.     uint8_t channel = 1;
  17.     uint8_t pos_trg = 0;
  18.     uart_init();
  19.     init_adc();
  20.     while (1)
  21.     {/*
  22.         r = calcVoltage(read_adc());
  23.         itoa(r,buffer,10);
  24.         uart_sendstr(buffer);
  25.         uart_sendstr(" mV ");
  26.        
  27.         _delay_ms(1000);*/
  28.    
  29.         // PENTRU TRIGGER NEGATIV
  30.         if(pos_trg == 0)
  31.         {
  32.             while(read_adc(channel)<VT_HI);
  33.             while(read_adc(channel)>VT_LO);        
  34.            
  35.             for(int i=0; i<bafarsaiz; i++)
  36.             {
  37.                 bufferCh0[i]=read_adc(0);
  38.                 bufferCh1[i]=read_adc(1);
  39.             }
  40.         }
  41.        
  42.         //PENTRU TRIGGER POZITIV
  43.         if(pos_trg == 1)
  44.         {
  45.             while(read_adc(channel)>VT_LO);
  46.             while(read_adc(channel)<VT_HI);
  47.            
  48.             for(int i=0; i<bafarsaiz; i++)
  49.             {
  50.                 bufferCh0[i]=read_adc(0);
  51.                 bufferCh1[i]=read_adc(1);
  52.             }
  53.         }
  54.            
  55.            
  56.            
  57.  
  58.         UART_SendOscData(bufferCh0,bufferCh1,bafarsaiz);
  59.     }
  60.    
  61.    
  62.    
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top