• 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
  • 0

Hi @rockxito32,

The sdk code looks right. We have not tested this functionality. As far as I can see there should not be any conflicts with using the ACL IP core more than once in a design. 

thank you,

Jon

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now