Sample Code Library

Sound frequency For Basic PRO Compiler

@ device pic16f877 define osc 4 define adc_bits 8 main: trisb =$00 trisa =$ff adcon1 = 7 speaker var portb.0 sw1 var porta.0 flg_set var bit speaker =0 flg_set =0 while(1) if(!sw1) then pause 150 toggle flg_set while(!sw1):wend endif gosub sounds pause 10 wend end sounds: if(flg_set)then pause 10 sound speaker,[100,10]’100 =(1-127 generate frequency 78.74-10

Sound frequency For Basic PRO Compiler Read More »

Timer 0 mode timer For CSS Compiler

  // Generator frequency 100 Hz with Timer0 For Pic16f877 // //#include “D:\MICRO_PICC_Group\timer\timer_0\timer_0_100hz.h” #include <16F877.h> #device adc=8 #FUSES NOWDT,XT //No Watch Dog Timer #use delay(clock=4000000) int1 time; #int_RTCC void RTCC_isr(void) { output_toggle(pin_b0); /* time =!time; if(time==1){ output_high(pin_b0); } if(time==0){ output_low(pin_b0); }*/ set_timer0(236); } void main() { setup_adc_ports(NO_ANALOGS); setup_adc(ADC_OFF); setup_psp(PSP_DISABLED); setup_spi(SPI_SS_DISABLED); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); enable_interrupts(INT_RTCC); enable_interrupts(GLOBAL);

Timer 0 mode timer For CSS Compiler Read More »