A clock program written using Xilinx's XPS tool

1. Configuration of GPIO peripherals:
(1) Create a new project, add three GPio peripherals, duan, wei, and Leds_8Bit, and connect them to the bus to set the address and corresponding length. Then set the GPio_d_out of the three added GPio ports under the port to make External to generate an external GPIO connection.
(2) Click on the UCF file under Project and add the ports of the corresponding three GPio peripherals. Then double-click Compiler OpTIons under ApplicaTIon, select Use Default Linker under Environment, and select No Optimization under Debug and OpTImizaTIon.
(3) Click the Compile button to compile.

2. Configuration of timers and interrupts:
(1) Double-click the XPS Timer/Counter timer in the DMA and Timer under the IP Catalog. Double-click XPS Interrupt... under Clock, Reset and Interrupt to add an interrupt. Change the name of the timer to delay and connect to the bus. Click on Generate Addresses under the address to add an address to it.
(2) Enter timer1 as the delay connection of the delay and pull down the interrupt to timer1. Create a new network by selecting New Connection from INTERRUPT under microblaze_0.
(3) Select microblaze_0_INTERRUPT under Irq. Click Intr to add timer1 from the pop-up window to the right window.
(4) Set CaptureTrig0 under delay to net_gnd.
(5) Double-click delay and select Only One Timer is present in the pop-up window.
(6) Finally add the written C file to the right in Sources under Application. Select Update under Device Configuration in the toolbar to compile. After the compilation is complete, click Download to download to the EXCD-1 board.

3. Extended function:
When the button is controlled, the points are added and subtracted.
(1) First add the button GPIO peripheral button, the setting method is the same as the first step. Note that when adding, don't forget to add its corresponding port in system.ucf.
(2) Then add the corresponding code in the C program. Define the global variable Xuint32 DataRead; //Read the number of buttons
XGpio Push_Bottons_4Bit; //Define GPIO button

Add a key initialization statement in the initialization function:

Status = XGpio_Initialize(&Push_Bottons_4Bit, XPAR_BUTTON_DEVICE_ID); //GPIO_BUTTONS_4BIT Initialization
XGpio_SetDataDirection(&Push_Bottons_4Bit, 1, 0xFFFFFFFF); //Set as input

Add a button scan function:
Void keyscan()

{
DataRead = XGpio_DiscreteRead(&Push_Bottons_4Bit, 1);//Read button information
If(DataRead == 0x7) //The first button
{
XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR);//Close interrupt
XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x0);
Delay(400);
DataRead = XGpio_DiscreteRead(&Push_Bottons_4Bit, 1);//Read button information

If(DataRead != 0x7)
{
Shi++;
If(shi==24)
Shi=0;
XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR);//Open interrupt again
XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1);
}
} / / There is only one scan here, if you want to increase the button, you can add a few more if

Bluetooth Headphones

Bluetooth Headphones,Best Bluetooth Headphones,On Ear Bluetooth Headphones,Wireless Bluetooth Earphones

TOPWAY EM ENTERPRISE LIMITED , https://www.topwayemltd.com

Posted on