ADC & PWM in 12F1501

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
oookay
Posts: 1
Joined: 12 Feb 2014 10:01

ADC & PWM in 12F1501

#1 Post by oookay » 12 Feb 2014 12:24

Hi all,

I’m using two ADC signals input to limit the PWM value, in the 12F1501.
ADC signal1 inputs to RA0, ADC signal2 inputs to RA1, PWM output from RA2.

I got stuck with this error message after compiled: “Not enough parameters 12F1501-PWM.c” pointing to this command: “PWM_Init1(500000);”

The program as follow:
// PIC 12F1501

unsigned short dutyVal, ADC_VAL;
unsigned short dutyVal, ADC_VAL1, ADC_VAL2,PWM_Init1(const long freq);
void InitMain() {
TRISA= 0B000011; //SET RA0 & RA1 INPUT.
CM1CON0 = 0;
CM1CON1 = 0; //OFF COMPARATORS
}

main(void) {
InitMain();
PWM_Init1(500000); // PWM FREQ 500KHz
PWM_Start1();
dutyVal = 153;
PWM_Start1();
while(1){
ADC_VAL1=ADC_Read(0);
ADC_VAL1 /= 4;
if ((unsigned short)ADC_VAL1>127) //if ADC_VAL1 over 127 PWM =0
{
dutyVal = 0;
PWM_Set_Duty1(dutyVal);}
ADC_VAL2=ADC_Read(1);
ADC_VAL2 /= 4;
if((unsigned short)ADC_VAL2>127)
{
dutyVal = 0;
PWM_Set_Duty1(dutyVal); }
else{PWM_Set_Duty1(dutyVal); // SET DUTY CYCLE
}
}

}

Error message:
0 1139 Available RAM: 48 [bytes], Available ROM: 1024 [bytes]
0 126 All files Preprocessed in 93 ms
0 122 Compilation Started 12F1501-PWM.c
19 314 Not enough parameters 12F1501-PWM.c
40 1503 Result is not defined in function: 'main' 12F1501-PWM.c
0 102 Finished (with errors): 12 Feb 2014, 18:57:16 12F1501-PWM.mcppi


Please any advice? Thanks
oookay

Acetronics
Posts: 715
Joined: 27 Dec 2006 14:33
Location: Le Tréport , FRANCE

Re: ADC & PWM in 12F1501

#2 Post by Acetronics » 13 Feb 2014 09:27

:roll:

just read Help chapter closer ( or once at least ! )...

Library Routines
PWM1_Init
PWM1_Set_Duty
PWM1_Start
PWM1_Stop
Alain

Post Reply

Return to “mikroC PRO for PIC General”