Hey,
ich habe ein kleines Projekt bei dem ich langsam echt verzweifle
Ich habe einen ADC der 500kSPS packt bei 12 Bit Auflösung. Ich nutze die BCM2835 libarary welche auch DMA unsterstützen soll. Ab einer Transfergröße von 96 Bytes sollte die Library das DMA automatisch akitiviert aktivieren(s. https://www.raspberrypi.org/forums/viewtopic.php?t=216532) . Wenn ich das die SCKL allerdings jetzt an ein Logic Analyzer lege, dann sehe ich immer noch die Lücken zwischen den einzelnen Bytes. So sollte es eigentlich aussehen:
Ohne DMA
Spoiler anzeigen
Mit DMA
Spoiler anzeigen
Hier mein Quellcode:
C
// Using C to read the MCP3008 10-bit
// ADC via SPI
#include <stdio.h>
#include <bcm2835.h>
int main(int argc, char const *argv[]) {
if (!bcm2835_init())
{
printf("bcm2835_init failed. Are you running as root??\n");
return 1;
}
if (!bcm2835_spi_begin())
{
printf("bcm2835_spi_begin failed. Are you running as root??\n");
return 1;
}
bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST); // The default
bcm2835_spi_setDataMode(BCM2835_SPI_MODE1); // The default
bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_16); // The default
bcm2835_spi_chipSelect(BCM2835_SPI_CS0); // The default
bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW); // the default
char tx0[70] = {0,0};
char rx[] = {0,0};
FILE *fp;
fp = fopen( "file.txt" , "w" );
for(int i=0; i<500; i++) {
bcm2835_spi_transfernb(tx0,rx,2);
fprintf(fp, "%02x%02x\n",rx[0],rx[1]);
}
fclose(fp);
return 0;
}
Alles anzeigen
Vielleicht hat ja der ein oder andere ein ähnliches Problem schon einmal gehabt und kann mir da weiterhelfen
Vielen Dank schon einmal im Voraus