On Tue, 18 May 2021 11:22:20 -0700 (PDT), in
gmane.comp.hardware.beagleboard.user Walter Cromer
<walterc-2dFtBuzUeF/[email protected]> wrote:


>Here's the code snippet with the two variables in bold.  If those lines of 
>code do not exist, the host doesn't hear from the PRU.

        Such formatting does not get through the gmane list<>newsgroup
interface. I'm going to presume you mean the lines with * markers. Posting
with a client that keeps indentation would also help... hard to keep track
of what is nested into what when everything is left justified with excess
blank lines.

        Normal recommendation is to condense the code down to the minimum that
still reproduces the problem, and to post the minimized files completely
(probably need both PRU and ARM programs). That allows others to attempt to
run/compare/debug.

>
> 
>
>count = HWREG(SOC_ADC_TSC_0_REGS + TSC_ADC_SS_FIFOCOUNT(0));
>
> 
>
>for (i = 0; i < count; i++) 
>
>{
>
>Data = HWREG(SOC_ADC_TSC_0_REGS + TSC_ADC_SS_FIFODATA(0));
>
>StepRead = (Data >> 16) & 0xF;
>
>RawAnalog = Data & 0xFFF;
>
> 
>
>switch (StepRead)
>
>{
>
>case 0:
>
> 
>
>DetTSampleSet[pnr]=RawAnalog;
>
>break;
>
>case 1:
>
>                                      
>
>*start_of_pulse = 0;*
>
>*end_of_pulse = 0;*

        Where were these declared?
>
> 
>
>DetBSampleSet[pnr]=RawAnalog;
>
>if ((pnr == end_of_pulse) && (in_pulse == E_YES)) // seen a pulse and at 
>end of it analyze signal

        Where is pnr defined/initialized? Same for in_pulse. 
>
>{
>
>DetBSignalAverage= AnalyzeSignal(start_of_pulse, pnr);
>
>start_of_pulse = -1;
>
>end_of_pulse = -1;
>

        If pnr is an index into some buffer, I'd probably use -1 to signal NO
DATA, and use the pnr values active at the time the pulse is detected for
start_of_pulse and the when the pulse ended for end_of_pulse

>samples_in_pulse = 0;
>
>in_pulse = E_NO;

        In a way, all these seem redundant: start&end at -1 indicates no data,
no samples, and not in a pulse. Samples_in_pulse at 0 indicates no data, no
samples, and likely not in a pulse. in_pulse at E_NO implies no data, no
samples.

        So, start&end are set to the appropriate pnr values... "in_pulse" is
indicated by start_of_pulse > -1 AND end_of_pulse = -1; "not in_pulse" is
indicated by (start_of_pulse > -1 AND end_of_pulse > -1) OR (start_of_pulse
= -1) //presumes you set both start/end to -1 at the same time

>
>if (start_of_pulse < 0) start_of_pulse = pnr;  // set start pointer in ring 
>buffer if it hasn't already been set for this pulse
>

        Okay, you do set start/end to the instantaneous pnr value... Just
emphasizes that samples_in_pulse and in_pulse are logically redundant and
hence a potential source of error (samples_in_pulse should be end - start
(maybe with a +1; do the math with a sample buffer). Note: if this is a
circular buffer you'll need to account for wrap-around.


-- 
Dennis L Bieber

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/bmk8ag1h4l4qsl9enn0ri3spm326qtbpdj%404ax.com.

Reply via email to