4 Replies Latest reply on Dec 14, 2011 1:54 AM by ki.leung

    Sinewave using PSoC3/5



      I have used the following code to generate a sinewave for freqiency 1 kHz.. But the frequency o/p that I'm getting is 35 Hz. Can anyone suggest me where I'm goin wrong? Also how do I use sine function with GCC compiler. If not supported, what's the other alternative ?


       #include <device.h>
      #include <math.h>


      #define PI 3.14159265


      void main()
         float frequency = 10000.0;
         float sample_per_seconds = 50000.0;
         int var=0;
         int i=0;
         i = 0;
        var = 255*(0.5 *(sin(2*PI*frequency*i/sample_per_seconds))+0.5);