
Det är koden som kommer från hjälpen (nästan iaf, nu med endast en pwm då 16f648a bara har en pwm)
Kod: Markera allt
unsigned short current_duty, old_duty;
void IO() {
TRISA = 0;
TRISB = 0b00000011;
PORTA = 0;
PORTB = 0;
PWM1_Init(5000);
}
void main() {
CMCON = 0x07;
IO();
current_duty = 16;
PWM1_Start(); // start PWM1
PWM1_Set_Duty(current_duty); // Set current duty for PWM1
while (1) { // endless loop
if (RB0_bit) { // button on RA0 pressed
Delay_ms(40);
current_duty++; // increment current_duty
PWM1_Set_Duty(current_duty);
}
if (RB1_bit) { // button on RA1 pressed
Delay_ms(40);
current_duty--; // decrement current_duty
PWM1_Set_Duty(current_duty);
}
Delay_ms(5); // slow down change pace a little
}
}
Kod: Markera allt
0 1 mikroCPIC1618.exe -MSF -DBG -pP16F648A -DL -O11111114 -fo4 -N"C:\Users\Pajn\Pic\in out test c\iotc.mcppi" -SP"C:\Program Files (x86)\Mikroelektronika\mikroC PRO for PIC\defs\" -SP"C:\Program Files (x86)\Mikroelektronika\mikroC PRO for PIC\Uses\P16\" -SP"C:\Users\Pajn\Pic\in out test c\" "iotc.c" "__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System.mcl" "__Lib_Delays.mcl"
0 125 All files Preprocessed in 15 ms
0 121 Compilation Started iotc.c
8 324 Undeclared identifier 'PWM1_Init' in expression iotc.c
16 324 Undeclared identifier 'PWM1_Start' in expression iotc.c
17 324 Undeclared identifier 'PWM1_Set_Duty' in expression iotc.c
23 324 Undeclared identifier 'PWM1_Set_Duty' in expression iotc.c
29 324 Undeclared identifier 'PWM1_Set_Duty' in expression iotc.c
0 102 Finished (with errors): 13 aug 2009, 21:09:00 iotc.mcppi
och hjälpen sägerCapture, Compare, PWM module:
- 16-bit Capture/Compare
- 10-bit PWM
CCP borde väl vara = Capture, Compare, PWM?Requires: MCU must have CCP module.