Forums » Software Development »
Simple Code/Doc for FPGA toggle of GPIO from DSP
Added by stefan nielsen almost 10 years ago
Hi im trying to toggle a pin in the FPGA from the DSP. Is there a doc(howto) describing the order of configuration/initialization and usage?.
Been looking at files from MDK_2014-01-13\sw\DSP\lib\core and MDK_2014-01-13\sw\common\fpga (fpga.h, fpga_gpio.h, DspFpgaGpio.cpp) but its still unclear to me what steps are involved.
ps. Got the HelloWorldDSP project running, so anything the could be added to it would be a bonus.
pps. The fpga(LX45) is loaded with .bin file from this thread: (https://support.criticallink.com/redmine/boards/12/topics/604)
thanks in advance
Stefan
Replies (7)
RE: Simple Code/Doc for FPGA toggle of GPIO from DSP - Added by stefan nielsen almost 10 years ago
Hi
If i want to toggle both pin 7 and pin 15 at the same time i have an issue (both work independently). Pin 7 goes high, but as soon an i write to pin 15 it goes low again. I tried with mpGpio->WritePins(0,0x3,1)/mpGpio->WritePins(0,0x3,0) doesn't work for me either only pin 7 goes high this way. Im measuring the pin in J702 with a scope.
//init
mpGpio = new tcDspFpgaGpio((void*)0x66000280);//GPIO
mpGpio->~tcDspFpgaGpio ();//clear isr callback
mpGpio->SetPinDirection(0, 0, TRUE, 0);
mpGpio->SetPinDirection(0, 1, TRUE, 0);
for(int kkk=0;kkk<10;kkk++)
{
mpGpio->SetPinValue(0,0,1); //pin 7 high
mpGpio->SetPinValue(0,1,1); //pin 15 high
for(int kki=0;kki<1000;kki++); //for delay
mpGpio->SetPinValue(0,0,0); //pin 7 low
mpGpio->SetPinValue(0,1,0); //pin 15 low
for(int kkii=0;kkii<1000;kkii++); //for delay
}
anybody got a hint as to what could be the cause ?
RE: Simple Code/Doc for FPGA toggle of GPIO from DSP - Added by Michael Williamson almost 10 years ago
Do you have the inputs of the GPIO core for offsets 0 and 1 connected in you FPGA design?
RE: Simple Code/Doc for FPGA toggle of GPIO from DSP - Added by stefan nielsen almost 10 years ago
Not sure what you mean with input ?,
both are mapped in the VHDL code as output. and set as output with SetPinDirection()
I can set both pin high, only not at the same time.
RE: Simple Code/Doc for FPGA toggle of GPIO from DSP - Added by Michael Williamson almost 10 years ago
The code for the DSP GPIO control does a read modify write. It Reads the input state of the entire bank, masks the value you are trying to change into the register, and writes the register back out.
If, in your VHDL, you do not connect the "i_io" pins to the Pad (output value), then the readback state of the output will not work properly, it will readback a "0" and then get written back to the register as a zero, turning off your IO.
Can you post a copy of the VHDL that has the GPIO component instantiated (don't need all the code).
-Mike
RE: Simple Code/Doc for FPGA toggle of GPIO from DSP - Added by Michael Williamson almost 10 years ago
The driver could be rewritten to contain a shadow mask of the desired output register, but that is not the current implementation.
-Mike
RE: Simple Code/Doc for FPGA toggle of GPIO from DSP - Added by Michael Williamson almost 10 years ago
Also, you should not be calling the destructor. This line is not OK:
mpGpio->~tcDspFpgaGpio ();//clear isr callback
Why are you trying to remove the ISR handler?
RE: Simple Code/Doc for FPGA toggle of GPIO from DSP - Added by stefan nielsen almost 10 years ago
Thank you, you where spot, it solved the issue with only having one pin high at a time.
The following works
mpGpio->SetPinValue(0,0,1); //pin7
mpGpio->SetPinValue(0,1,1); //pin15
if i use
mpGpio->WritePins(0,0xFFFF,1); //all pins
only pin 7 goes high, any ideas ?
thanks