c - Program run correctly only in debug mode -


To test the board display with a button to toggle between hex and BCD mode, just a microbase c The application was written.

Here is my code:

  #include & lt; Xparameters.h & gt; # Include & lt; Xgpio.h & gt; Int main () {XGpio display, number, bcd, butt; // Define four variables named design, number, bcd, but int flag = 1; XGpio_Initialize (and display, XPAR_AXI_GPIO_0_DEVICE_ID); XGpio_SetDataDirection (and display, 1.0); // Set XGpio_Initialize (and digit, XPAR_AXI_GPIO_1_DEVICE_ID) set as output port; XGpio_SetDataDirection (and digits, 1,0); // Set XGpio_Initialize (& amp; BCD, XPAR_AXI_GPIO_2_DEVICE_ID) as the output port; XGpio_SetDataDirection (and BCD, 1.0); // Set BCD as output port XGpio_Initialize (& amp; butt, XPAR_AXI_GPIO_3_DEVICE_ID); XGpio_SetDataDirection (and butt, 1,1); // Set button as input port while (1) {if (XGpio_DiscreteRead (and butt, 1) == 1) {if (flag == 1) {flag = 0; } Else {flag = 1; }} // Toggle Flag XGpio_DiscreteWrite (and BCD, 1, Flag); // set to bcd XGpio_DiscreteWrite (and digits, 1, 7); // set n ° 8 points XGpio_DiscreteWrite (and display, 1, 99563243); // Type to display}}  

When I debug on the board, it's all right. Toggle does not work after downloading FPGA

Why can anyone explain this?

The following code runs fine. By defining the flag as a UOF and adding the delay cycle.

  Add # & lt; Xparameters.h & gt; #to & lt include, xgpio.h & gt; Int main () {XGpio display, number, BCD, SH; // defined GPIO variable long end delay; // Define a delay variable u32 flag = 1; // Define a Flag Variable XGpio_Initialize (& Display, XPAR_AXI_GPIO_0_DEVICE_ID); XGpio_SetDataDirection (& amp; Display, 1.0); // Set XGpio_Initialize (and digit, XPAR_AXI_GPIO_1_DEVICE_ID) set as output port; XGpio_SetDataDirection (& amp; Numerals, 1,0); // Set XGpio_Initialize (& amp; BCD, XPAR_AXI_GPIO_2_DEVICE_ID) as the output port; XGpio_SetDataDirection (& amp; BCD, 1.0); // Set BCD as output port XGpio_Initialize (& SW, XPAR_AXI_GPIO_3_DEVICE_ID); XGpio_SetDataDirection (& amp; 1,1); // set as input port, while (1) {flag = XGpio_DiscreteRead (& sw, 1); XGpio_DiscreteWrite (and BCD, 1, flag); // set to bcd XGpio_DiscreteWrite (and digits, 1, 7); // set n ° 8 points XGpio_DiscreteWrite (& Display, 1, 5888999); Type to display for // (delay = 0; delay & lt; 3000000; delay ++) {}; // delay cycle}}  

Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

c# - WPF Expander overlay used in ItemsControl -

class - Kivy: how to instantiate a dynamic classes in python -