fx2lp timer

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
gean_3054931
Level 5
Level 5
10 likes given 5 likes given First like received

Hello,

fx2lp pin 50 is connected to another device.i wanted to generate 2 mili second pulse(active high) from this pin.

so i am using timer for delay genaration.i need 2ms active pulse .how to make pin no 50 initaily low .

fx2lp is operating at 24MHZ,TIMER run at the same rate,

how to put this in code.??

pin 50 at logic low

2ms_delay();    //pin 50 at logic 1 upto 2 mili seconds.

pin 50 at logic low.

regards.

0 Likes
1 Solution

Hello Geethanjali,

Please let know if the mentioned implementation is suitable to your application.

PD5 = 0; // Drive LOW

if(<condition>)

{

PD5 = 1; // Drive HIGH

EZUSB_Delay(2);   // Generate 2 ms delay

PD5 = 0; // Drive it LOW

}

Best regards,
Srinath S

View solution in original post

0 Likes
26 Replies
SrinathS_16
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello Geethanjali,

I assume that you are using FX2LP in the 56-pin QFN package and the FX2LP is used in either PORTS mode (or) 8-bit slave FIFO mode. Please correct me if I am wrong.

In that case, to drive the pin active HIGH for 2ms, the EZUSB_Delay() function call can be used.

PD5 = 1; // Drive HIGH

EZUSB_Delay(2);   // Generate 2 ms delay

PD5 = 0; // Drive it LOW

Please let know if this implementation would suit your application.

Best regards,

Srinath S

Hi sir,

you are right,I am using FX2LP in the 56-pin QFN package,FX2LP is used in 8-bit slave FIFO mode.

Pin should be active HIGH for 2ms,after that it should be low and before 2ms high delay,pin should be low.

please see the diagram.

regards,

Geethanjali.

0 Likes

timer.bmp

0 Likes

Hello Geethanjali,

Please let know if the mentioned implementation is suitable to your application.

PD5 = 0; // Drive LOW

if(<condition>)

{

PD5 = 1; // Drive HIGH

EZUSB_Delay(2);   // Generate 2 ms delay

PD5 = 0; // Drive it LOW

}

Best regards,
Srinath S

0 Likes

Hello shrinath,

what is that condition?how can i go through this?

regards,

geethanjali.

0 Likes

Hi,

The condition will be nothing but when do you want to toggle the GPIO, if you just wish to toggle always irrespective of any condition, then can have it without condition.

For example, I have a requirement where I have to turn on a LED for 2mS when a button is pressed.

In this example I might place the pseudo code might look like as below:

if(button_pressed)

{

     Toggle LED which can be achieved may be driving a GPIO

     LED_ON;

     Delay(2) // 2mS Delay

     LED_OFF;

}

Thank you & regards,

Sudheer

Hello,

I have written above code in my firmwre with OED=0x20;,but i cant see pulse at this pin when i probe with oscilloscope.

did i miss anything?is it any register or configuration is there to make pin as output or input?

regards,

geetha.

0 Likes

Hello Geetha,

- The OEx register of the corresponding port to which the used GPIO belongs must be set such that the pin is configured as an output.

- For example, in case you are using PA1 as output, the following line would configure the pin.

    OEA = 0x02;

Best regards,

Srinath S

0 Likes

Hello shrinath,

I have used OED=0x20; for PD5 port.but i dint get the pulse on this pin.

regards,

geetha.

0 Likes

Hello Geetha,

- Please check if you have used the IOD |= 0x20 and IOD |= 0x00 statements after you have configured the pin using the OED = 0x20 statement.

- OEA register setting only configures the pin as an output pin. IOA register has to be written with the value to drive the pin either HIGH or LOW.

Best regards,

Srinath S

Hello shrinath,

PD.5=0; ->This statement is not enough to drive the pin to low?

are you saying that to replace PD.5=0 to IOD=0x20?

regards,

geetha.

0 Likes

Hello Geetha,

- PD5 = 0 or PD5 = 1 can also be used to drive the pin. Please let me know if you are using it this way.

- Please share the code snippet and also the waveform captured on this pin.

Best regards,

Srinath S

0 Likes

void TD_Init( void )

{  

  CPUCS = 0x02; /// CLKSPD[1:0]=01, for 24MHz operation, output CLKOUT

  PINFLAGSAB = 0x08; // FLAGA - EP2EF

  SYNCDELAY;

  PINFLAGSCD = 0xE0; // FLAGD - EP6FF

  SYNCDELAY;

  OED=0x20;                 //ENABLE PD.5

// IOD=0x20;

  EZUSB_InitI2C();

  IFCONFIG = 0x03;  // external clock, synchronous, Slave FIFO interface,OE disabled.

  SYNCDELAY;

  // EP4 and EP8 are not used in this implementation...              

  EP2CFG = 0xE2;                //in 512 bytes, 4x, bulk

  SYNCDELAY;

  EP6CFG = 0xE0;                //in 512 bytes, 4x, bulk

  SYNCDELAY;             

  EP4CFG = 0xA2;                //out 512 bytes.4x,bulk

  SYNCDELAY;                    

  EP8CFG = 0x02;                //clear valid bit(not used)

  SYNCDELAY;  

  FIFORESET = 0x80;             // activate NAK-ALL to avoid race conditions

  SYNCDELAY;                    // see TRM section 15.14

  FIFORESET = 0x02;             // reset, FIFO 2

  SYNCDELAY;                    //

  FIFORESET = 0x04;             // reset, FIFO 4

  SYNCDELAY;                    //

  FIFORESET = 0x06;             // reset, FIFO 6

  SYNCDELAY;                    //

  FIFORESET = 0x08;             // reset, FIFO 8

  SYNCDELAY;                    //

  FIFORESET = 0x00;             // deactivate NAK-ALL

  FIFOPINPOLAR = 0x04; // Setting SLWR active HIGH

  SYNCDELAY;

  EP6FIFOCFG = 0x00;

// EP6FIFOCFG = 0x08;

  SYNCDELAY;                    

  EP6AUTOINLENH = 0x02;

  SYNCDELAY;

  EP6AUTOINLENL = 0x00;

  SYNCDELAY;

  PORTACFG = 0x02;

  TCON |= 0x04;

  IE |= 0x84;

  PX1 = 1;

EZUSB_WriteI2C(Image_Sensor, 0x03, REG012);

EZUSB_WriteI2C(Image_Sensor, 0x01, REG014);

}

void TD_Poll( void )

{

PD5 = 1; // Drive HIGH

EZUSB_Delay(100);   // Generate 100 ms delay

PD5= 0; // Drive it LOW

//SYNCDELAY;

}

0 Likes

Hello shrinath,

anything wrong with the above code snippet?

regards,

geetha.

0 Likes
lock attach
Attachments are accessible only for community members.

Hello Geetha,

- The above mentioned TD_Poll() function block is fine and it works. Please refer to the image attached.

- Please check:

1. Device enumeration is fine without any errors

2. Hardware connection on the PD5 pin is proper.

Best regards,

Srinath S

Hello shrinath,

1)Its enumearting properly,i am able to recieve proper data in IN bulk ENDPOINT.

2)PD5 pin is connected to one of  the pin of image sensor,its directly connected to image sensor(without any pullup/pulldown resistor,series register).

regards,

geetha.

0 Likes

Hello Geetha,

Please let me know how do you identify the pin is not toggling. In case you are probing the lines, kindly, share the screenshot.

Best regards,

Srinath S

Hello shrinath,

yes,i am probing the pin PD5 and checking the same with oscilloscope.

its not toggling,just showing single line.

regards,

geetha.

0 Likes

Hello shrinath,

I am getting this warning message,is it because of this?but its build with 0 errors and 0 warnings.

and i2c read and write function works as expected.

regards,

geetha.i2c.bmp

0 Likes
lock attach
Attachments are accessible only for community members.

Hello Geetha,

Please load the shared IIC file into the device and check if the pin is toggling. If it works fine, then it is a problem with you firmware. If it does not work, then it is a problem with your hardware.

Best regards,

Srinath S

0 Likes

Hello shrinath,

please share the .hex file.

regards,

geetha.

0 Likes
lock attach
Attachments are accessible only for community members.

Hello Geetha,

Attached is the HEX file.

Best regards,

Srinath S

0 Likes

Hello shrinath,

I probe the PD5 pin,its not togling?I am getting no signal found in cro.

regards,

geetha.

0 Likes

Hello Geetha,

I tested this firmware on the FX2LP DVK and I could see the toggling on PD5 pin which I had shared as a screenshot. So, this seems like an hardware issue on your board. Kindly, recheck your onboard connections and ensure you are probing it properly.

Best regards,

Srinath S

Hello shrinath,

If i set IFCONFIG=0x03; i.e.slavefifo configuration,led is not blinking.

if i comment IFCONFIG=0x03; i.e. default port mode,led is blinking.

can't i use FD[8:15] or PD[0:7] pins as GPIO when its in slavefifo configuration with 8 bit data bus(WORDWIDE=0).

regards,

geetha.

0 Likes

Hello shrinath,

PD3 pin is connected to led.

if i use this below code,led is blinking with bulkloop.c example project.

TD_Init()

{

OED=0x08;

IO=0x08;

}

If i use above code in slave.c slavefifo configuration,led is not blinking.

I have set EP6FIFOCFG=0x00; //WORDWIDE=0;

Why this is happening?

regards,

geetha.

0 Likes