Skip to content
Snippets Groups Projects
Commit 7ac753e9 authored by James Talbert's avatar James Talbert
Browse files

Add a duty cycle sweep test

The test has the user install a loopback jumper, then tests that the record/generate match at 1% intervals. The error currently holds at 18 cycles (probably a filter thing).
parent b65c0d6c
No related branches found
No related tags found
No related merge requests found
/****************************************************************************** /******************************************************************************
* *
* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved. * Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* Use of the Software is limited solely to applications: * Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or * (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect. * (b) that interact with a Xilinx device through a bus or interconnect.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
* *
* Except as contained in this notice, the name of the Xilinx shall not be used * Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in * in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx. * this Software without prior written authorization from Xilinx.
* *
******************************************************************************/ ******************************************************************************/
/* /*
* helloworld.c: simple test application * helloworld.c: simple test application
...@@ -48,14 +48,47 @@ ...@@ -48,14 +48,47 @@
#include <stdio.h> #include <stdio.h>
#include "platform.h" #include "platform.h"
#include "xil_printf.h" #include "xil_printf.h"
#include "xparameters.h"
#include "xuartps.h"
#include "sleep.h"
int main() {
init_platform();
volatile uint32_t* buttonsGPIO =
(volatile uint32_t*) (XPAR_AXI_GPIO_2_BASEADDR);
volatile uint32_t* pwmRecord =
(volatile uint32_t*) (XPAR_PWM_RECORDER_0_S_AXI_BASEADDR);
volatile uint32_t* pwmGenerate =
(volatile uint32_t*) (XPAR_PWM_SIGNAL_OUT_0_S_AXI_BASEADDR);
print(
"Please connect JB0 and JB1 with an external jumper.\r\nWhen ready, press any button.\n\r");
while (buttonsGPIO[0] == 0)
;
print("Thank You :)\r\n");
int main() pwmGenerate[0] = 50 * 1000;
{ pwmGenerate[1] = 25 * 1000;
init_platform();
print("Hello World\n\r"); int iteration;
const int num_iterations = 100;
for (iteration = 0; iteration < num_iterations; iteration++) {
pwmGenerate[1] = (iteration * pwmGenerate[0]) / num_iterations;
usleep(10000);
cleanup_platform(); int error = pwmRecord[0] - pwmGenerate[1];
return 0; int abserror = error;
if (abserror < 0) {
abserror = -error;
}
xil_printf("%3d%% Duty Cycle: %c%3d.%08d%% error\r\n",
(100 * pwmGenerate[1]) / pwmGenerate[0],
(error < 0) ? '-' : ' ',
(100 * abserror) / ((int) pwmGenerate[0]),
((10000000000 * abserror) / ((int) pwmGenerate[0]))
% 100000000);
}
cleanup_platform();
return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment