| Line 1... |
Line 1... |
| 1 |
#include "C:\RS\kaki\try\mainpw2.h" |
1 |
#include <16F877A.h> |
| - |
|
2 |
#device adc=8 |
| 2 |
|
3 |
|
| - |
|
4 |
#FUSES NOWDT //No Watch Dog Timer |
| - |
|
5 |
#FUSES XT //Crystal osc <= 4mhz |
| - |
|
6 |
#FUSES NOPUT //No Power Up Timer |
| - |
|
7 |
#FUSES NOPROTECT //Code not protected from reading |
| - |
|
8 |
#FUSES NODEBUG //No Debug mode for ICD |
| - |
|
9 |
#FUSES NOBROWNOUT //No brownout reset |
| - |
|
10 |
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
| - |
|
11 |
#FUSES NOCPD //No EE protection |
| - |
|
12 |
#FUSES WRT_50% //Lower half of Program Memory is Write Protected |
| 3 |
|
13 |
|
| 4 |
void main() |
- |
|
| 5 |
{ |
- |
|
| 6 |
int8 delay; |
- |
|
| 7 |
setup_adc_ports(AN0); |
14 |
#use delay(clock=4000000) |
| 8 |
setup_adc(ADC_CLOCK_DIV_2); |
- |
|
| 9 |
setup_psp(PSP_DISABLED); |
- |
|
| 10 |
setup_spi(SPI_SS_DISABLED); |
- |
|
| 11 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
15 |
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) |
| 12 |
setup_timer_1(T1_DISABLED); |
- |
|
| 13 |
setup_timer_2(T2_DIV_BY_1,8,1); |
- |
|
| 14 |
setup_ccp1(CCP_PWM); |
- |
|
| 15 |
set_pwm1_duty(0); |
- |
|
| 16 |
setup_comparator(NC_NC_NC_NC); |
- |
|
| 17 |
setup_vref(FALSE); |
- |
|
| 18 |
|
16 |
|
| 19 |
while(TRUE) |
- |
|
| 20 |
{ |
- |
|
| 21 |
delay=read_adc(); |
- |
|
| 22 |
set_pwm1_duty((delay)); |
- |
|
| 23 |
} |
- |
|
| 24 |
} |
- |
|