cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

user_3678521
New Contributor II

Hello,

I'm making a color sensor (TCS3200), and i have a issue trying to make a function that works the same way as pulsin() from arduino.

In a code i take my output value like this on arduino: PulsIn() function definition from arduino 

  // Reading the output frequency

  greenFrequency = pulseIn(sensorOut, LOW);

and i have to do somthing like that on PSoC creator.

Right now i only get 0 and 1 as output (the value of what i set my pins to).

rgb.JPG

in the attached code you can see what im trying to do.

Thanks

0 Likes
1 Solution
MotooTanaka
Esteemed Contributor

Hi,

The PulsIn() seems to be a frequency counter.

The following document seems to be very helpful.

http://www.cypress.com/file/144696/download

I also tried this with PSoC 5LP board, as I don't have the sensor

I fed the pulse from my funcgen program with another MCU

via Pin P6[6] as SensorOut.

It is measuring frequency (Hz), so probably you need to adjust counter parameters.

TeraTermLog.JPG

Attached is my test project based on your project.

I hope this can be a little help.

moto

View solution in original post

5 Replies
AnkitaS_51
Employee

Hi,

There is no direct replacement for PulseIn Function in Creator.

You may have to use a GPIO and Timer  or PWM and interrupt to implement similar functionality.

These links may be useful:

Reading From an Output Pin

Read data from input pin

0 Likes
MotooTanaka
Esteemed Contributor

Hi,

The PulsIn() seems to be a frequency counter.

The following document seems to be very helpful.

http://www.cypress.com/file/144696/download

I also tried this with PSoC 5LP board, as I don't have the sensor

I fed the pulse from my funcgen program with another MCU

via Pin P6[6] as SensorOut.

It is measuring frequency (Hz), so probably you need to adjust counter parameters.

TeraTermLog.JPG

Attached is my test project based on your project.

I hope this can be a little help.

moto

View solution in original post

user_3678521
New Contributor II

I can see that you use the:

volatile uint32_t dummy;

what is this variable used for?

Because its set but not used.

0 Likes
MotooTanaka
Esteemed Contributor

Hi,

Actually it was a little bit difficult for me to use these two counters.

During the debug, when the loop timeout-ed, I wanted to check the

frequency count without overwriting the real value, so I used dummy.

Then as you noticed, as I did not use dummy anywhere else,

the compiler optimized the variable so I could not see the value

from the debugger. Then I used "volatile" key word to prevent the

compiler to opt-out the variable.

Anyway, now it does not affect anything else... I hope.

moto

user_3678521
New Contributor II

Thanks for the fast respons btw, it REAALY helped me alot

0 Likes