LoginSignup
0
1

More than 5 years have passed since last update.

ZYBO > GPIO Pmod出力の波形測定 > 27MHz程度は出そう?

Last updated at Posted at 2016-07-09
動作環境
DIGILENT ZYBO
Analog Discovery 2 (以下AD2)
Vivado 2015.4 on Windows 8.1 pro (64bit)

cnt使用

http://qiita.com/7of9/items/2e714e66d4a6c78c4a02
をベースに以下のソフトに変更した。

helloworld.c
#include <stdio.h>
#include "xparameters.h"
#include "xgpio.h"
#include "platform.h"

#define PMOD_DEVICE_ID  XPAR_AXI_GPIO_0_DEVICE_ID

XGpio PMODInst;

int main()
{
    init_platform();

    print("Hello World\n\r");

    int status;
    status = XGpio_Initialize(&PMODInst, PMOD_DEVICE_ID);
    if (status != XST_SUCCESS) {
        print("LED initialize failure\r\n");
        return -1;
    }
    XGpio_SetDataDirection(&PMODInst, 1, 0);
    XGpio_DiscreteWrite(&PMODInst, 1, 0x0F);

    int cnt = 0;
    while(1) {
        cnt++;
        if (cnt == 1000) {
            XGpio_DiscreteWrite(&PMODInst, 1, 0xF0);
        }
        if (cnt == 2000) {
            XGpio_DiscreteWrite(&PMODInst, 1, 0x0F);
            cnt = 0;
        }
    }

    cleanup_platform();
    return 0;
}

cnt2000周期での波形の出力をしている。

対応するPmod コネクタのピン1つをAD2のChannel 1で取込んだ。

qiita.png

1周期が37usecになっている。

1秒 / 37usec = 27027Hz
= 27kHz

2000カウントに対して27kHz.
2カウントにすると27Mhz程度が出るのだろうか。

ZYBOのZynqは650MHz。

qiita.png

usleep使用

XillinxのAPIとしてusleep()という関数があるようだ。usleep()を使うように変更してみた。

helloworld.c
#include <stdio.h>
#include "xparameters.h"
#include "xgpio.h"
#include "platform.h"

#define PMOD_DEVICE_ID  XPAR_AXI_GPIO_0_DEVICE_ID

XGpio PMODInst;

int main()
{
    init_platform();

    print("Hello World\n\r");

    int status;
    status = XGpio_Initialize(&PMODInst, PMOD_DEVICE_ID);
    if (status != XST_SUCCESS) {
        print("LED initialize failure\r\n");
        return -1;
    }
    XGpio_SetDataDirection(&PMODInst, 1, 0);
    XGpio_DiscreteWrite(&PMODInst, 1, 0x0F);

    int cnt = 0;
    while(1) {
        usleep(50);
        XGpio_DiscreteWrite(&PMODInst, 1, 0xF0);
        usleep(50);
        XGpio_DiscreteWrite(&PMODInst, 1, 0x0F);
    }

    cleanup_platform();
    return 0;
}

100usecの周期が取れた。

qiita.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1