本文整理汇总了C++中setup_adc函数的典型用法代码示例。如果您正苦于以下问题:C++ setup_adc函数的具体用法?C++ setup_adc怎么用?C++ setup_adc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setup_adc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
}
示例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
}
示例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');
}
}
}
示例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
}
}
示例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);
}
示例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
}
}
示例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
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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!
}
示例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
}
}
}
示例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);
}
}
}