This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

problem when Writing to GPIOs through Macro

Hello everyone.

 

I’m using Control card TMS320F2803x Piccolo, I want to set some switches in my application.

 At the beginning I use specific way to close the switches together witch worked perfectly, I just write to GPADAT register.

GpioDataRegs.GPADAT.bit.GPIO16 = 1;

GpioDataRegs.GPADAT.bit.GPIO18 = 1;

GpioDataRegs.GPADAT.bit.GPIO26 = 1;

--------------------------

I try to define the GPIOs in Macro :

#define OPEN_SWITCH1_COMMAND   (GpioDataRegs.GPADAT.bit.GPIO16 = 0)
#define CLOSE_SWITCH1_COMMAND (GpioDataRegs.GPADAT.bit.GPIO16 = 1)

#define OPEN_SWITCH2_COMMAND (GpioDataRegs.GPADAT.bit.GPIO26 = 0)
#define CLOSE_SWITCH2_COMMAND (GpioDataRegs.GPADAT.bit.GPIO26 = 1)


#define OPEN_SWITCH3_COMMAND (GpioDataRegs.GPADAT.bit.GPIO18 = 0)
#define CLOSE_SWITCH3_COMMAND (GpioDataRegs.GPADAT.bit.GPIO18 = 1)

And I try to close the switches like it look below:

CLOSE_SWITCH1_COMMAND;

CLOSE_SWITCH2_COMMAND;

CLOSE_SWITCH3_COMMAND;

It doesn’t work, the GPADAT register doesn’t updated.

but  if  I adding above 5  nops after every command like it look below :

CLOSE_SWITCH1_COMMAND;

NOP;NOP;NOP;NOP;NOP;

CLOSE_SWITCH2_COMMAND;

NOP;NOP;NOP;NOP;NOP;

CLOSE_SWITCH3_COMMAND;

It works rightly.

Can someone tell me the reason why it happened ?

Best Regards

Adel