Hi Hans!

Am Mittwoch, 8. Mai 2019 18:54:37 UTC+2 schrieb Hans Leeuw:
>
> I set it at the maximum size for the moment although it can be a little 
> smaller indeed.... I forgot to make it smaller in my example. I think it is 
> not important for the resolution issue though.
>

When the size of the ERam is too small the main loop doesn't start -> no 
ADC sampling at all. You'll get garbage.
 

> Starting the outer loop at 0 wil only lead to printing the step cycle one 
> compleet cycle earlier (from the start) but does not change the resolution 
> either.
>

Correct!

Where do I fail to catch an error message?
>

A lot of errors are uncatched. This version catches them all

#include "stdio.h"
#include "libpruio/pruio.h" // include header
#include <unistd.h>

int main(int argc, char **argv)
{
  int i = 1, n;
  char *emsg = "CTOR";
  pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0);
  while (!io->Errr) {
    if (pruio_adc_setStep(io,  7, 0, 1, 0, 0)) {emsg = "step  7"; i = 2; 
break;} //Step  7, AIN-0
    if (pruio_adc_setStep(io,  8, 1, 1, 0, 0)) {emsg = "step  8"; i = 2; 
break;} //Step  8, AIN-1
    if (pruio_adc_setStep(io,  9, 2, 1, 0, 0)) {emsg = "step  9"; i = 2; 
break;} //Step  9, AIN-2
    if (pruio_adc_setStep(io, 10, 3, 1, 0, 0)) {emsg = "step 10"; i = 2; 
break;} //Step 10, AIN-3
    if (pruio_adc_setStep(io, 11, 4, 1, 0, 0)) {emsg = "step 11"; i = 2; 
break;} //Step 11, AIN-4
    if (pruio_adc_setStep(io, 12, 5, 1, 0, 0)) {emsg = "step 12"; i = 2; 
break;} //Step 12, AIN-5
    if (pruio_adc_setStep(io, 13, 6, 1, 0, 0)) {emsg = "step 13"; i = 2; 
break;} //Step 13, AIN-6
    if (pruio_adc_setStep(io, 14, 7, 1, 0, 0)) {emsg = "step 14"; i = 2; 
break;} //Step 14, AIN-7

    // upload settings, prepare MM mode
    if (pruio_config(io, 220500, 255<<7, 45352, 0)) {emsg = "config";   i = 
3; break;}
    // start measurement   //Starts in rb_mode
    if (pruio_rb_start(io))                         {emsg = "rb_start"; i = 
4; break;}
    printf("initialized\n");
    usleep(10000);
  /* now current ADC samples are available for AIN-0 to AIN-7 in array 
io->Adc->Value[] */
    for(n = 0; n <= 13; n++) { //                       print some lines
      for(i = 0; i < 8; i++) //                                all steps
        printf(" %4X", io->Adc->Value[i + (8 * n)]); //  output one channel 
in hex
      printf("\n"); //                                         next line
      }
    i = 0;
  }
/* we're done */
  if (io->Errr) printf("%s failed (%s)\n", emsg, io->Errr);

  pruio_destroy(io);        /* destroy driver structure */
  return i;
}

Try it. You also can check the available ERam size by printing out io->ESize
.

 

> The documentation also mentions a status bit that is used to indicate that 
> the ADC is busy converting (page 1828). Is the status bit information used 
> in the rb-mode?
>

Yes, the status bit gets checked for restart as well as the FiFo counter 
before fetching a sample.

Regards

-- 
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/607744f4-6055-44f7-9439-e88b32feb95f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to