Are you trying to read 3 pulses in a row or a pulse that is 3 x wider than
some reference pulse ?
Normally you would use a counter to count the pulses if former, or a
timer to measure pulse width for latter case. If former case do the 3 pulses
have to occur within some time limit window ?
I am trying to read three pulses in a row, where there are ex 50 us between them. Can't I use a pin to read the pulses and then stored them in variable?
The problem is your code defines when they will get detected, versus
notifying you with an interrupt that 3 have occured.
I would use a down counter, set its period to 2, and use an ISR on its Tc, terminal
count. In ISR you set a flag, and reset counter, in main() process the flag.
Okay thanks. One more question. I have also problems starting the ADC.
uint8 variabel = 0;
uint8 buffer = 0;
uint8 a = 0;
uint8 b = 0;
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
/* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
variabel = ADC_GetResult8();
/* Place your application code here. */
Is your A to D named "ADC" or ADC_DelSig_1" ? If latter
you have several f()'s you are calling with the wrong name
associated with the A to D.
If former then
If latter then
and the others used below these.
The ADC is named ADC. I think it might be something else?
Keep in mind you can always open an example project, add to your workspace, and
look at it, deleting it from workspace when done.
Consider posting your project, makes life easier to troubleshoot.
“Create Workspace Bundle”
You need to enable interrupts before starting your ADC.
CyGlobalIntEnable ? I am testing by putting the VDD pin into the ADC pin.. Still not working
Odd, the datasheet only implies single sample mode needs interrupts
enabled, and TRM only seems to confirm if you want to use an interrupt
you can, otherwise poll.
variabel = ADC_GetResult8();
You should use GetResult16, and declare variable as int16 -
Description: Returns a signed 8-bit value. The largest positive signed 8-bit value that can be represented
is 127, but in single-ended 8-bit mode, the maximum positive value is 255. Hence, for 8-bit
single-ended mode, use the ADC_GetResult16() function instead. Note that if the ADC
resolution is set greater than 8 bits, the LSB of the result is returned.
float ADC_CountsTo_Volts(int32 adcCounts)
Description: Converts the ADC output to volts as a floating point number. For example, if the ADC
measures a voltage of 1.2345 V, the returned result would be +1.2345 V.
buffer now has a cast of the float in it back to uint8, not a char string which is what you need to send
via UART. Note when you call CountsTo_Volts cast variable to a int32 in the call. Note you need
the receiving variable to be a float.
now use sprintf() to fill a new char buffer which you should create with the chars that represent the float,
and use the send string api in UART API set.
Attached the formatting chars to use for sprintf().
printf_1.pdf 81.5 K