- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i tried to convert a analog signal to a digital one,using LED7SEG to show it ,but after adding the timer8 ,the system just don't work ,can you help?
this is my code ,thank you !
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#pragma interrupt_handler timer
int TimerCount=0;
int iResult;
int i;
void main()
{
M8C_EnableGInt;
PGA_1_Start(PGA_1_MEDPOWER);
ADCINC12_1_Start(ADCINC12_1_MEDPOWER);
ADCINC12_1_GetSamples(0);
Timer8_1_Start();
Timer8_1_EnableInt();
LED7SEG_1_Start();
while(1)
{
if(ADCINC12_1_fIsDataAvailable()!=0)
{
iResult=ADCINC12_1_iGetData()+2048;
ADCINC12_1_ClearFlag();
iResult=iResult*5000.0/4096.0;
LED7SEG_1_DispInt(i,1,4);
if(iResult>2000)
{
PWM8_1_Start();
}
if(iResult<=2000)
{
PWM8_1_Stop();
}
}
}// Insert your main routine code here.
}
void timer()
{
TimerCount+=1;
if(TimerCount==128)
{
i=iResult;
TimerCount=0;
}
}
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you let us know about your hardware setup. Are you using a Cypress Development kit for development or any custom board. Can you as well let us know which device you are trying to use.