|
i also want to massure frequency here i am useing counter as kmmankand suggest.its easy way then useing timer but here i get some problem here at every 100 hz pssout frequency display more than real
foe example after 100hz
120display as 103on lcd
after 200hz input
210 display as 212hz and so on ..........
i dont know why this hapen.....
here i attech my project and code
here is code
---------------------------------------------------------------------------------------------------------------
#include <device.h>
uint16 K,V,C,D,E,f,m;
uint8 A,state,Z,O;
float freq;
unsigned long int l;
void init (void)
{
LCD_Seg_1_Start();
Counter_1_Start() ;
isr2_Start();
}
void calculation(void)
{
V=m;
l=12000000/V;
}
void dataupdate(void)
{
E=l;
state ^=0xFF; //for led toggel
out1_Write(state);
}
void main()
{
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
CYGlobalIntEnable; /* Uncomment this line to enable global interrupts. */
init();
for(;;)
{
if(A==1)
{
calculation(); /* Place your application code here. */
dataupdate();
A=0;
}
}
}
/* [] END OF FILE */
CY_ISR(isr2_Interrupt)
{
/* Place your Interrupt code here. */
/* `#START isr2_Interrupt` */
//{
//z++;
Counter_1_ReadStatusRegister();
m=Counter_1_ReadCapture();
A=1;
/* `#END` */
/* PSoC3 ES1, ES2 RTC ISR PATCH */
#if(CYDEV_CHIP_DIE_EXPECT == CYDEV_CHIP_DIE_LEOPARD)
#if((CYDEV_CHIP_REV_EXPECT <= CYDEV_CHIP_REV_LEOPARD_ES2) && (isr2__ES2_PATCH ))
isr2_ISR_PATCH();
#endif
#endif
}
-------------------------------------------------------------------------------------------------------------------------------------------------
|