• 0
rockxito32

Usign multiple PmodACL with Zedboard by SPI

Question

Hi everyone, In this opportunity I want to establish a SPI communication between two PmodACL and a Zedboard, in Vivado software I done it this way:

a1.thumb.png.a39d2677bddf785c44b1fae0ff76e579.png

And I got the Bitstream file without any mistake. But how can I do the SDK configuration for read two PmodACL at the same time?

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @rockxito32,

The process is very similar to this forum thread. You will need to instantiate multiple structs. Something like:

PmodACL acl;

PmodACL acl1;

In the DemoInitialize()  function you will need to call the functions twice. So for example ACL_begin twice one for acl and one for acl1

Spoiler

 

ACL_begin(&acl, XPAR_PMODACL_0_AXI_LITE_GPIO_BASEADDR,
         XPAR_PMODACL_0_AXI_LITE_SPI_BASEADDR);

ACL_begin(&acl1, XPAR_PMODACL_1_AXI_LITE_GPIO_BASEADDR,
         XPAR_PMODACL_1_AXI_LITE_SPI_BASEADDR);

 ACL_SetMeasure(&acl, 0);
 ACL_SetMeasure(&acl1, 0); 

 ACL_SetGRange(&acl, ACL_PAR_GRANGE_PM4G);

ACL_SetGRange(&acl1, ACL_PAR_GRANGE_PM4G);
ACL_SetMeasure(&acl, 1);

ACL_SetMeasure(&acl1, 1);
ACL_CalibrateOneAxisGravitational(&acl, ACL_PAR_AXIS_ZP);

ACL_CalibrateOneAxisGravitational(&acl1, ACL_PAR_AXIS_ZP);

then in your while loop you will call ACL_ReadAccelG and the printf function twice.

ACL_ReadAccelG(&acl, &x, &y, &z);

printf("X=%f\tY=%f\tZ=%f\n\r", x, y, z);
      usleep(100000);

ACL_ReadAccelG(&acl1, &x, &y, &z);

printf("X=%f\tY=%f\tZ=%f\n\r", x, y, z);
      usleep(100000);

 

thank you,

Jon

 

 

 

 

Share this post


Link to post
Share on other sites
  • 0

Thank you for your soon response

Then, it'll be something like that:

#include "xparameters.h"
#include "xil_cache.h"
#include "PmodACL.h"

#include <stdio.h>

#ifdef __MICROBLAZE__
#include "microblaze_sleep.h"
#else
#include <sleep.h>
#endif

void DemoInitialize();
void DemoRun();
void DemoCleanup();
void DemoSleep(u32 millis);
void EnableCaches();
void DisableCaches();

PmodACL acl;
PmodACL acl1;

int main(void)
{
    DemoInitialize();
    DemoRun();
    DemoCleanup();
    return 0;
}

void DemoInitialize()
{
    EnableCaches();
    ACL_begin(&acl, XPAR_PMODACL_0_AXI_LITE_GPIO_BASEADDR,XPAR_PMODACL_0_AXI_LITE_SPI_BASEADDR);
    ACL_begin(&acl1, XPAR_PMODACL_1_AXI_LITE_GPIO_BASEADDR,XPAR_PMODACL_1_AXI_LITE_SPI_BASEADDR);
    ACL_SetMeasure(&acl, 0);
    ACL_SetMeasure(&acl1, 0);
    ACL_SetGRange(&acl, ACL_PAR_GRANGE_PM4G);
    ACL_SetGRange(&acl1, ACL_PAR_GRANGE_PM4G);
    ACL_SetMeasure(&acl, 1);
    ACL_SetMeasure(&acl1, 1);
    ACL_CalibrateOneAxisGravitational(&acl, ACL_PAR_AXIS_ZP);
    ACL_CalibrateOneAxisGravitational(&acl1, ACL_PAR_AXIS_ZP);
    DemoSleep(1000); // After calibration, some delay is required for the new settings to take effect.
}

void DemoRun()
{
    float x, y, z;

    while (1)
    {
        ACL_ReadAccelG(&acl, &x, &y, &z);
        printf("PmodACL 0");
        printf("X=%f\tY=%f\tZ=%f\n\r", x, y, z);
        DemoSleep(1000);

        ACL_ReadAccelG(&acl1, &x, &y, &z);
        printf("PmodACL 1");
        printf("X=%f\tY=%f\tZ=%f\n\r", x, y, z);
        DemoSleep(1000);
    }
}

void DemoCleanup()
{
    DisableCaches();
}

void DemoSleep(u32 millis)
{
#ifdef __MICROBLAZE__
    MB_Sleep(millis);
#else
    usleep(1000 * millis);
#endif
}

void EnableCaches()
{
#ifdef __MICROBLAZE__
#ifdef XPAR_MICROBLAZE_USE_ICACHE
    Xil_ICacheEnable();
#endif
#ifdef XPAR_MICROBLAZE_USE_DCACHE
    Xil_DCacheEnable();
#endif
#endif
}

void DisableCaches()
{
#ifdef __MICROBLAZE__
#ifdef XPAR_MICROBLAZE_USE_DCACHE
  Xil_DCacheDisable();
#endif
#ifdef XPAR_MICROBLAZE_USE_ICACHE
  Xil_ICacheDisable();
#endif
#endif
}
 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.