• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setup_adc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中setup_adc函数的典型用法代码示例。如果您正苦于以下问题:C++ setup_adc函数的具体用法?C++ setup_adc怎么用?C++ setup_adc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setup_adc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

void main() {
   BYTE i, j, address, value;

   int16 q,q1;
   float p;

   q1=0;
   
   setup_adc_ports(AN0|VSS_VDD);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(0);

   usb_cdc_init();
   usb_init();

//      while(!usb_cdc_connected()) {}

   do {
      usb_task();
      if (usb_enumerated()) {

      delay_ms(500);
      q = read_adc();
      if (q!=q1){
      p = 5.0 * q / 1024.0;
      printf(usb_cdc_putc,"\r Voltage=%01.2fV", p);
      }
      q1=q;
   }
      } while (TRUE);
}
开发者ID:mafairnet,项目名称:mafUsbProBoard,代码行数:31,代码来源:T10_E1.c


示例2: main

void main ()
{
  set_tris_a(0xff);//se pone el puerto RA analogo de entrada
  set_tris_d(0x00);//se pone el puerto RD en salida para prender los led

  setup_adc_ports(ALL_ANALOG);//configuracion de los puertos analogos
  setup_adc(ADC_CLOCK_DIV_32);//el osilador del ADC

  while (true)
  {

    set_adc_channel(0);
    delay_us(10);
    valor = read_adc();
    if(valor){
      output_d(0x01);
    }else{
      output_d(0x00);
    }

    set_adc_channel(1);
    delay_us(10);
    valor = read_adc();
    if{
      output_d(0x02);
    }else{
      output_d(0x00);
    }
  }
开发者ID:cceballosq,项目名称:robotica7A,代码行数:29,代码来源:practica10.c


示例3: init_pic

void init_pic()
{
   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_DIV_32);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_counters( RTCC_INTERNAL, RTCC_DIV_1 | RTCC_8_BIT);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);

   EXT_INT_EDGE(L_TO_H);

   OUTPUT_B(0);
   OUTPUT_C(0);

   SET_TRIS_B(0b01000111);   //pins B0, B1 and B2 are set to give inputs. b0 is the external interuupt pin
   SET_TRIS_C(0b00000000);
   SET_TRIS_D(0b00000000);

   set_adc_channel(0);            //the next read_adc call will read channel 0
}
开发者ID:Manuri,项目名称:People-counting-and-fan-speed-controlling-system,代码行数:26,代码来源:testing3+adc_a.c


示例4: main

void main()
{
   
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   
   TX = 0;
   RX = 1;
   
   TRIS_B = 0x00;
   
   while(1)
   {
      //putc(getc());
      LED = 1;
      delay_ms(300);
      
      LED = 0;
      delay_ms(300);
      
      if(verificaFlag())
      {
         if(recebeByte())
            enviaByte('T');
      }      
   }
}
开发者ID:JaconsMorais,项目名称:repcomputaria,代码行数:33,代码来源:rs+232_2.c


示例5: main

void main(){
   
   //CHAR letA[]="A";
   //CHAR letB[]="B";
   //CHAR letC[]="C";
   //CHAR espera[]="teste";
   
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);

   glcd_init(ON);   //inicializa o display
   glcd_fillScreen(0); //limpa display inteiro
   
   //glcd_text57(34, 55, letA, 1, 1);
   //glcd_rect(46,53,60,63,1,1);
   //glcd_text57(48,  55, letB, 1, 0);

   while(TRUE){
   
   glcd_imagem(1);
   delay_ms(3000);
   glcd_fillScreen(0); //limpa display inteiro
   glcd_imagem(2);
   delay_ms(3000);
   glcd_fillScreen(0); //limpa display inteiro
   
   }
}
开发者ID:ezequieldonhauser,项目名称:DISPLAY_128x64,代码行数:35,代码来源:main.c


示例6: main

main() {

    int i,value,min,max;

    printf("Sampling:");

    setup_port_a( ALL_ANALOG );
    setup_adc( ADC_CLOCK_INTERNAL );
    set_adc_channel( 0 );

    do {
        min=255;
        max=0;
        for(i=0; i<=30; ++i) {
            delay_ms(100);
            value = Read_ADC();
            if(value<min)
                min=value;
            if(value>max)
                max=value;
        }
        printf("\n\rMin: %2X  Max: %2X\r\n",min,max);

    } while (TRUE);

}
开发者ID:joristork,项目名称:robots,代码行数:26,代码来源:EX_ADMM.C


示例7: main

//---------------------------------
   void main()
{  //#byte TRISB=0b11000000;
   SET_TRIS_B(0xC0);    //configura PORTB entrada / 0=salida / 1=entrada
   OUTPUT_D(0x00);   //inicializando PORTD en 0x00
   //#byte PORTB=0x00;
   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);//|RTCC_8_bit);      //51.2 us overflow
  // setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);      //13.1 ms overflow

  // setup_ccp1(CCP_COMPARE_SET_ON_MATCH);

  // enable_interrupts(INT_RTCC);
   enable_interrupts(INT_RTCC);
   enable_interrupts(GLOBAL);
   cont=0;
   comp1=0;

   while(TRUE)
   {

   set_adc_channel(0);
   delay_ms(1);//tiempo  de offset necesario
   comp1=((read_adc())/1024.0*250.0); 
   delay_ms(1);//tiempo  de offset necesario
 
   }

}
开发者ID:JOTAI,项目名称:SistemasEmbebidos2014-I,代码行数:30,代码来源:PWM_Timer.c


示例8: init_pic

void init_pic()
{
   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_DIV_32);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_counters( RTCC_INTERNAL, RTCC_DIV_1 | RTCC_8_BIT);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);

   EXT_INT_EDGE(L_TO_H);

   OUTPUT_B(0);
   OUTPUT_C(0);

   SET_TRIS_B(0b01000111);   //pins B0, B1, B2 and B6 are set to give inputs. B0 is the external interuupt pin
                             //B0, B1 & B2 are used for people counting. B6 for zero crossing detection in fan controlling
   SET_TRIS_C(0b00000000);
   SET_TRIS_D(0b00000000);   //D port except D0 pin, is used for lcd panel

   set_adc_channel(0);            //the next read_adc call will read channel 0
}
开发者ID:Manuri,项目名称:People-counting-and-fan-speed-controlling-system,代码行数:27,代码来源:testing3+adc_c.c


示例9: main

void main()
{
   int16 valor;
   float tensao;
   lcd_init();



   setup_adc_ports(AN0|VSS_VDD);
   setup_adc(ADC_CLOCK_DIV_16);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   set_adc_channel(0);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

   // TODO: USER CODE!!

   while(1)
   {
      valor = read_adc();
      tensao = valor*5.0/1024.0;
      printf("ADC = %04ld",valor);
      printf("    Tensao = %.3fV\r", tensao);
      printf(lcd_putc,"\fADC = %ld",valor);
      printf(lcd_putc,"\nTensao = %.3fV",tensao);
      delay_ms(250);
   }
   
}
开发者ID:romajr,项目名称:Control_PIC_projects,代码行数:35,代码来源:3ºexemplo.c


示例10: main

void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32|RTCC_8_bit);   //RTCC_DIV_32 -> 122 Hz ou 30 Hz por nivel
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(INT_EXT);
   enable_interrupts(INT_EXT1);
   enable_interrupts(GLOBAL);

   
   set_tris_a (0b11110000);
   set_tris_c (0b00000000);
   set_tris_d (0b00000000);
   
   
   while(1){
	delay_ms(10);
   }

}
开发者ID:gjasper,项目名称:PIC-based-4x4x4-LED-Cube-controller,代码行数:30,代码来源:CUBO_LEDS_4X4.c


示例11: init_prog

//=============================================================================
void init_prog(void)
{
setup_wdt(WDT_OFF);
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);                                                
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16|RTCC_8_BIT);// TIMER0
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);                                           
setup_vref(FALSE);
setup_low_volt_detect(FALSE);              
setup_oscillator(OSC_32MHZ);                                        

set_tris_a(0xFF);//7F
set_tris_b(0xFF); //FF
set_tris_c(0x94);//94
set_tris_d(0xFF); //02                                     
set_tris_e(0xF0);  //f0   
set_tris_f(0xFF);//ff
set_tris_g(0xFC); //04
output_a(0x00);
output_b(0x00);
output_c(0x00);
output_d(0x00);
output_e(0x00);
output_f(0x00);
output_g(0x00);
}
开发者ID:suleymancanan,项目名称:RFID-PRJ-TX,代码行数:32,代码来源:ddd.c


示例12: setup

// Setup ports and ADC config
void setup()
{
	SET_TRIS_C(0); // Sets PORT C to output only
    setup_adc_ports(sAN2);
    setup_adc(adc_clock_internal);
    set_adc_channel(2);
}
开发者ID:kyluke,项目名称:16F690,代码行数:8,代码来源:main.c


示例13: main

int main(void)
{
	BCSCTL1 = CALBC1_1MHZ;
	DCOCTL  = CALDCO_1MHZ;
	Max1.index = -1;
	Max1.magnitude = 0;
	Max2.index = -1;
	Max2.magnitude = 0;


	// setup the watchdog timer as an interval timer
	WDTCTL =(WDTPW +	// (bits 15-8) password
	                    // bit 7=0 => watchdog timer on
	                    // bit 6=0 => NMI on rising edge (not used here)
	                    // bit 5=0 => RST/NMI pin does a reset (not used here)
	       WDTTMSEL +   // (bit 4) select interval timer mode
	       WDTCNTCL + 	// (bit 3) clear watchdog timer counter
	  		            // bit 2=0 => SMCLK is the source
	  		   2        // bits 1-0 = 10 => source/512 .
	);

	IE1 |= WDTIE;		// enable the WDT interrupt (in the system interrupt register IE1)

	 // in the CPU status register, set bits:
	 //    GIE == CPU general interrupt enable
	 //    LPM0_bits == bit to set for CPUOFF (which is low power mode 0)

	setup_adc();

	init_pwm_timer0(PWM_PERIOD, 0, BIT2); //Pin 2, port of port A. Initially off
	init_pwm_timer1((PWM_PERIOD*1.5), 0, BIT4);

	_bis_SR_register(GIE/*+LPM0_bits*/);  // after execution of this instruction, the CPU is off!
}
开发者ID:johanos,项目名称:MSP430-Projects,代码行数:34,代码来源:mainA.c


示例14: main

int main (void)
{
	

	int dummy;
	//int matrix; //only for test of ledmdrv
	int i;
	//int temp_current_val; //temporary
	//int first_ec=1;
	//Setup oscillator/ports/pins first
	setup_oscillator();
	setup_ports();
	setup_peripheral_pin_select();
	setup_interrupt_priorities();

#ifdef USE_DIO
	setup_dio();
#endif

#ifdef USE_ADC
	setup_adc();
#endif




#ifdef USE_ETHERCAT

	while (!eeprom_loaded())		//Wait until ESC is ready
		//ToggleHeartbeatLED();				//Success
		SetHeartbeatLED;
	setup_ethercat();
	ClrHeartbeatLED;

#endif



setup_interrupt_priorities();

dummy = U1RXREG;

	while(1){





		if (i++%20001==0)
		{
			ToggleHeartbeatLED();
#if defined USE_ETHERCAT //&& ! defined M3_MAX2_BDC_ARMH
		step_ethercat();
#endif
			
			
		}

	} 
}
开发者ID:CentralLabFacilities,项目名称:m3meka,代码行数:60,代码来源:main.c


示例15: main

void main()
{

   setup_adc_ports(ALL_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   // TODO: USER CODE!!
   
      set_adc_channel(0);            // set ref valus
      delay_ms(100);
      ref_0 =read_adc();
      delay_ms(100);
      
      set_adc_channel(3);            // set ref valus
      delay_ms(100);
      ref_3 =read_adc();
      delay_ms(100);
   
   output_b(0b11111111);
   delay_ms(700);
   output_b(0);
   
   while(1){
      set_adc_channel(0);
      delay_ms(20);                        // take readings
      adc_val_0 =read_adc();
      delay_ms(20);
      if(adc_val_0 > ref_0+cons){
         l_0 =1;
         output_high(pin_d7);
         delay_ms(500);
      }
      else{
         l_0=0;
         output_low(pin_d7);
     //    delay_ms(500);
      }
      
      set_adc_channel(3);
      delay_ms(20);                        // take readings
      adc_val_3 =read_adc();
      delay_ms(20);
      if(adc_val_3> ref_3+cons){
         l_3 =1;
         output_high(pin_d6);
         delay_ms(500);
      }
      else{
         l_3=0;
         output_low(pin_d6);
      }
   }
}
开发者ID:isurusanjeewa,项目名称:Line-Following-Robot,代码行数:60,代码来源:2_sen.c


示例16: main

void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_EXT);
   ext_int_edge(L_to_H);
   enable_interrupts(GLOBAL);
   output_low(PIN_B7);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

   // TODO: USER CODE!!
   
   while(TRUE)
   {
   }

}
开发者ID:romajr,项目名称:Control_PIC_projects,代码行数:25,代码来源:3º+Exemplo.c


示例17: main

void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);

while (TRUE) {

      printf("\r\nSinyali Baslatmak icin B tusuna basiniz");
      if (getchar() == 'b')         //eðer b tuþuna basarsan
      {
         printf("\n1 hz sinyal aktif edildi\r");
            while (1) {
               output_high(PIN_B0);
               delay_ms(500);
               output_low(PIN_B0);
               delay_ms(500);
            }
      }
   }
}
开发者ID:akinayturan,项目名称:programing-microprocessor-examples,代码行数:26,代码来源:rs232.c


示例18: main

void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16|RTCC_8_bit);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_RTCC);
   enable_interrupts(INT_EXT);
   enable_interrupts(INT_EXT1);
   enable_interrupts(GLOBAL);
   
   set_tris_a (0b11110000);
   set_tris_b (0b00000000);
   set_tris_c (0b00000000);
   
   cubeLevelC0 = 0xFF;
   cubeLevelC1 = 0x00;
   cubeLevelC2 = 0xFF;
   cubeLevelC3 = 0x00;
   
   cubeLevelD0 = 0x00;
   cubeLevelD1 = 0xFF;
   cubeLevelD2 = 0x00;
   cubeLevelD3 = 0xFF;

}
开发者ID:gjasper,项目名称:PIC-based-4x4x4-LED-Cube-controller,代码行数:33,代码来源:CUBO_LEDS_4X4+-+BACKUP.c


示例19: main

void main(void){

	int8_t data=0;
	setup_adc(ADC_CLOCK_DIV_8);
	//ADCのサンプリング設定	

	setup_wdt(WDT_1152MS);
	while(1){
		restart_wdt();/*
		output_high(PIN_A0);
		output_low(PIN_A1);
		output_high(PIN_A2);
		//以上アドレスピン設定
		output_low(PIN_A3);
		output_low(PIN_A4);
		output_high(PIN_A5);
		//以上エネーブルピン設定*/
		output_a(0b00001111);
		setup_adc_ports(ALL_ANALOG);
		set_adc_channel(6);
		/*
		ここでADCを適用できるピンと実際に適用するピンを決めます。
		ちなみに仕様として各ピンの役割を個別に設定できないようです。
		ですがすべてアナログに設定しても問題なくエネーブルピンやアドレスピンは動いてくれているので見なかったことにしましょう。
		*/
		delay_us(20);
		restart_wdt();
		data=read_adc();
		setup_adc_ports(NO_ANALOGS);//一応戻しています。
		putc((char)data);
		sleep();
	}
}
开发者ID:ARTSAT,项目名称:INVADER,代码行数:33,代码来源:ADCandMultiplexerSample.c


示例20: main

int main(void)
{
    unsigned char ret;

    DDRB  = 0xff;                              // use all pins on port B for output 
    PORTB = 0x00;                              // (LED's low & off)

    i2c_init();                                // init I2C interface

    ret = i2c_start(DevSSD1306+I2C_WRITE);       // set device address and write mode
    if ( ret ) {
        /* failed to issue start condition, possibly no device found */
        i2c_stop();
        PORTB=0xff;                            // activate all 8 LED to show error */
    }
    else {
    /* issuing start condition ok, device accessible */
    setup_i2c();
    setup_adc();
    }
    for(;;){
        clearBuffer(buffer);

        // get accelerometer values
        sample_adc_channel(1);
        sample_adc_channel(2);
        sample_adc_channel(3);

        PORTB=0x00;
        drawBuffer(0, 0, buffer);
        PORTB=0xFF;
        _delay_ms(500);

    }
}
开发者ID:umotes,项目名称:avr-clean-new,代码行数:35,代码来源:volt_ssd.c



注:本文中的setup_adc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setup_clear_cpu_cap函数代码示例发布时间:2022-05-30
下一篇:
C++ setupVBO函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap