Jump to content

microblaze mcs


Recommended Posts

 

Hi. I try to use four  gpio on microblaze mcs. Two for imput and two por output. I can only  read one input/output port. This is the verilog code. 

module TopMod(
    input sys_clk,
    input reset,
    input [7:0] sw,
    output [7:0] leds, 
    input [7:0] sw1,
   output [7:0] leds1
    );
     
  microblaze_mcs_0 mcs_0 (
    .Clk(sys_clk),                  
    .Reset(reset),                  
    .GPIO1_tri_i(sw),     
   .GPIO1_tri_o(leds),   
    .GPIO2_tri_i(sw1),    
    .GPIO2_tri_o(leds1) 
  );

   endmodule

and this is the sdk/ lenguaje c code


#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xparameters.h"
#include "xiomodule.h"
int main()

{

    init_platform();
   u32 data1;
   u32 data2;
   XIOModule gpi;
   XIOModule gpo;
   XIOModule gpi_1;
   XIOModule gpo_1;
    data1 = XIOModule_Initialize(&gpi, XPAR_IOMODULE_0_DEVICE_ID);
    data1 = XIOModule_Start(&gpi);
    data1 = XIOModule_Initialize(&gpo, XPAR_IOMODULE_0_DEVICE_ID);
    data1 = XIOModule_Start(&gpo);

    data2 = XIOModule_Initialize(&gpi_1, XPAR_IOMODULE_0_DEVICE_ID);
    data2 = XIOModule_Start(&gpi_1);
    data2 = XIOModule_Initialize(&gpo_1, XPAR_IOMODULE_0_DEVICE_ID);
    data2 = XIOModule_Start(&gpo_1);
    while (1)

    {

       data1 = XIOModule_DiscreteRead(&gpi, 1); // read switches (channel 1)
      XIOModule_DiscreteWrite(&gpo, 1, data1); // turn on LEDs (channel 1)
       data2 = XIOModule_DiscreteRead(&gpi_1, 1); // read switches (channel 2)
      XIOModule_DiscreteWrite(&gpo_1, 1, data2); // turn on LEDs (channel 2)

    }

    cleanup_platform();

    return 0;

}

Can say to me whats is the problem?

Thanks

FF

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...