- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am new to PSOC and i am facing error "requires ANSI-style prototype".
This is the code
#include <device.h>
#include "stdio.h"
#include "math.h"
/* Number of samples to be taken before averaging the ADC value */
void main()
{
/* Start both DACs */
IDAC1_MSD_Start();
IDAC2_LSD_Start();
/* Sets both IDACs to source current */
IDAC1_MSD_SetPolarity(IDAC1_MSD_SOURCE);
IDAC1_MSD_SetPolarity(IDAC2_LSD_SOURCE);
/* Sets proper ranges */
IDAC1_MSD_SetRange(IDAC1_MSD_RANGE_2mA );
IDAC2_LSD_SetRange(IDAC2_LSD_RANGE_255uA);
/*facing problem in this line*/
iDAC11_SetValue(12) ;
}
/* 11-Bit SetValue function. */
void iDAC11_SetValue(uint16 dacValue)
{
uint8 msb, lsb;
/* Split data into 2 bytes */
msb = (uint8)(dacValue >> 3);
lsb = (uint8)((dacValue << 0) & 0x07);
/* Write values */
IDAC1_MSD_SetValue(msb);
IDAC2_LSD_SetValue(lsb);
}
Please reply ASAP its urgent.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Before main() declaration in listing declare the prototype for the
function call :
void iDAC11_SetValue( uint16 ) ;
.
.
.
main() {
..
..
..
}
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also make sure your IDAC component is named IDAC1, not
IDAC1_1_......
Regards, Dana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Today's C-language needs to know what kind of rerturn-value and what parameters a function has before it is called the first time. This is named "declaration" of a function prototype. It has the form
returntype FunctionName(Parametertypelist);
Usually to improve parameter understanding, a name can be posted after a parametertype which is meaningless for code generation but improves readability, for example
BOOL GetValveState(uint16 PressureValue);
main()
while GetValveState(OutSideBar) ...
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually C does allow a parameterless prototype, but good compilers complain.
http://en.wikipedia.org/wiki/Function_prototype
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dana, Thanks for helping to fix the PSOC related compilatation errors.
I also had same issue of " requires ANSI-style prototype" in my PSOC3 compilation.
I made a mistake of not declaring function call before main(). After I have declared function call correctly as below before main()
void PIN_3V3_BCM_ON_write(uint8)
the error "ERROR: .\main.c:100: 'PIN_3V3_BCM_ON_write': requires ANSI-style prototype
The command 'c51.exe' failed with exit code '2' is disappeared.
Thanks,
Suresh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you terminate the declaration with a ";" ?
Another possibility, you mispelled the call in the code after declaration.
Some compilers complain about a line number, and it's actually the prior
line of code that is at issue.......
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dana, Yes.. I had ";" after decleration
void PIN_3V3_BCM_ON_write(uint8);
and actually there was no mispel/case senstive change for this call in my code after decleration.
Thanks,
Suresh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How about upload your project so people here can check for you.