/Designs/Measuring_instruments/GM_counter/SW/HV_source/main.c
23,20 → 23,6
 
#define OUTPUT_ENABLE PIN_C1
 
 
//#define MAXDUTY (int16)160 // 50 kHz
#define MAXDUTY (int16)400 // 20 kHz
//#define MAXDUTY (int16)800 // 10 kHz
#define HALFDUTY (int16)MAXDUTY/2
//#define DIVISOR 199 // 10 kHz
#define DIVISOR 99 // 20 kHz
//#define DIVISOR 39 // 50 kHz
 
#define regreseM (2.02)
#define regreseN (-451)
 
 
 
void sound_beep( unsigned int lenght, int16 frequency)
{
unsigned int i;
54,17 → 40,15
unsigned int16 napeti;
unsigned int16 plneni=0;
unsigned int1 button_press; // semafor pro cteni tlacitek
unsigned int16 reg;
float given;
 
setup_adc_ports(sAN0|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_adc(ADC_CLOCK_DIV_32);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_1,DIVISOR,1);
set_pwm1_duty(HALFDUTY);
set_pwm2_duty(MAXDUTY);
setup_timer_2(T2_DIV_BY_1,255,1);
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
setup_oscillator(OSC_8MHZ);
 
78,7 → 62,6
output_low(BEEP);
 
lcd_init();
set_adc_channel(0);
lcd_gotoxy(1,1);
lcd_putc("HVPS01A");
87,10 → 70,6
Delay_ms(1000);
lcd_putc("\f");
 
reg=400;
given=regreseM*reg+regreseN;
 
while(true)
{