Hello All,
Has anybody had issues completing lab 5 successfully in the ZynqIntro folder... The value that I send to the UART is getting written over by garbage values returned back from the UART? For example I enter the value 1 and the LEDs get set to the right level of lighting but some how the inbyte function gets some values while polling and it gets written over by garbage value. Is this a response back from the UART?
Heres the output:
Select a Brightness between 0 and 9
1
Brightness Level 1 selected
Select a Brightness between 0 and 9
Brightness Level -35 selected
Select a Brightness between 0 and 9
Brightness Level -38 selected
Select a Brightness between 0 and 9
Here's the C code:
/*
* main.c
*
* Created on: Jul 13, 2013
* Author: shep
*/
#include "xparameters.h"
#include "xgpio.h"
/*
* The following constant maps to the name of the hardware instances that
* were created in the EDK XPS system.
*/
#define GPIO_EXAMPLE_DEVICE_ID XPAR_AXI_GPIO_0_DEVICE_ID
/*
* The following constant is used to determine which channel of the GPIO is
* used for the LED if there are 2 channels supported.
*/
#define LED_CHANNEL 1
/************************** Variable Definitions *****************************/
/*
* The following are declared globally so they are zeroed and so they are
* easily accessible from a debugger
*/
XGpio Gpio; /* The Instance of the GPIO Driver */
/*
* The following constant is used to determine which channel of the GPIO is
* used for the LED if there are 2 channels supported.
*/
#define LED_CHANNEL 1
/******************************************************************************/
int main(void)
{
int Status;
u32 value = 0;
u32 period = 0;
u32 brightness = 0;
/*
* Initialize the GPIO driver
*/
Status = XGpio_Initialize(&Gpio, GPIO_EXAMPLE_DEVICE_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
// Clear
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, 0);
while (1) {
print("Select a Brightness between 0 and 9
r");
value = inbyte();
period = value - 0x30;
xil_printf("Brightness Level %d selected
r", period);
brightness = period * 110000;
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, brightness);
}
return XST_SUCCESS;
}