程序如下,怎么就不行呢。
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
void delay(char x);
BYTE bResult;
void main(void)
{
M8C_EnableGInt;
SAR8_SelectADCChannel(SAR8_P0_0);
SAR8_SetRunMode(SAR8_FreeRun);
SAR8_Start();
while(1)
{
while (0 == SAR8_fIsDataAvailable()); // wait for result
bResult = SAR8_bGetData();
delay(bResult);
LED_1_Invert();
}
// Insert your main routine code here.
}
void delay(BYTE x)
{
char y;
for(;x>0;x--)
{
for(y=0;y<100;y++){;}
}
} |