Driving MKW22D512 transceiver GPIOs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Driving MKW22D512 transceiver GPIOs

Jump to solution
1,495 Views
augustosala
Contributor II

In the MKW22D512 there are some GPIOs connected to the transceiver (modem gpios) like GPIO2, instead of being mcu controlled, but I couldn't find any information on the reference manual, as well as the source code generated with beekit, on how to drive these gpios. Is there some code, example or documentation I could have a look? At the moment I need to set gpio2 as output and drive it high and low.

Thanks for your time.

Labels (1)
0 Kudos
1 Solution
1,328 Views
georgecapraru
NXP Employee
NXP Employee

Hi,

I have attached updated MC1324xDrv files which contains API for controlling XCVR GPIO pins:

        void MC1324xDrv_SetGpioPinAsOutput(uint8_t GpioMask);

        void MC1324xDrv_SetGpioPinAsInput(uint8_t GpioMask);

        void MC1324xDrv_SetGpioPin(uint8_t GpioMask);

        void MC1324xDrv_ClearGpioPin(uint8_t GpioMask);

        uint8_t MC1324xDrv_GetGpioPinValue(uint8_t GpioMask);

        void MC1324xDrv_EnableGpioPullUp(uint8_t GpioMask);

        void MC1324xDrv_EnableGpioPullDown(uint8_t GpioMask);

        void MC1324xDrv_DisableGpioPullUpDown(uint8_t GpioMask);

        void MC1324xDrv_EnableGpioHiDriveStrength(uint8_t GpioMask);

        void MC1324xDrv_DisableGpioHiDriveStrength(uint8_t GpioMask);

       

       

Example:

        /* Output pin */

        MC1324xDrv_SetGpioPinAsOutput(gMC1324x_GPIO2_d);

        MC1324xDrv_EnableGpioHiDriveStrength(gMC1324x_GPIO2_d);

        MC1324xDrv_SetGpioPin(gMC1324x_GPIO2_d); //set to logic 1

        MC1324xDrv_ClearGpioPin(gMC1324x_GPIO2_d); // set to logic 0

        /* Input pin */

        MC1324xDrv_SetGpioPinAsInput(gMC1324x_GPIO2_d);

        MC1324xDrv_EnableGpioPullUp(gMC1324x_GPIO2_d);

        uint8_t value = MC1324xDrv_GetGpioPinValue(gMC1324x_GPIO2_d);

Regards,

George

View solution in original post

5 Replies
1,329 Views
georgecapraru
NXP Employee
NXP Employee

Hi,

I have attached updated MC1324xDrv files which contains API for controlling XCVR GPIO pins:

        void MC1324xDrv_SetGpioPinAsOutput(uint8_t GpioMask);

        void MC1324xDrv_SetGpioPinAsInput(uint8_t GpioMask);

        void MC1324xDrv_SetGpioPin(uint8_t GpioMask);

        void MC1324xDrv_ClearGpioPin(uint8_t GpioMask);

        uint8_t MC1324xDrv_GetGpioPinValue(uint8_t GpioMask);

        void MC1324xDrv_EnableGpioPullUp(uint8_t GpioMask);

        void MC1324xDrv_EnableGpioPullDown(uint8_t GpioMask);

        void MC1324xDrv_DisableGpioPullUpDown(uint8_t GpioMask);

        void MC1324xDrv_EnableGpioHiDriveStrength(uint8_t GpioMask);

        void MC1324xDrv_DisableGpioHiDriveStrength(uint8_t GpioMask);

       

       

Example:

        /* Output pin */

        MC1324xDrv_SetGpioPinAsOutput(gMC1324x_GPIO2_d);

        MC1324xDrv_EnableGpioHiDriveStrength(gMC1324x_GPIO2_d);

        MC1324xDrv_SetGpioPin(gMC1324x_GPIO2_d); //set to logic 1

        MC1324xDrv_ClearGpioPin(gMC1324x_GPIO2_d); // set to logic 0

        /* Input pin */

        MC1324xDrv_SetGpioPinAsInput(gMC1324x_GPIO2_d);

        MC1324xDrv_EnableGpioPullUp(gMC1324x_GPIO2_d);

        uint8_t value = MC1324xDrv_GetGpioPinValue(gMC1324x_GPIO2_d);

Regards,

George

1,328 Views
augustosala
Contributor II

Thank you George,

the routines provided work properly.

A second question I have now is if one can configure these GPIO to reflect TX/RX operation or other internal states of the modem.

I have a power amplifier connected to GPIO2 and would like to turn it on only during transmission.

I could also set GPIO2 manually in the code before and after each tramission but I'm wondering where could I do this as it seems to me that the internal functions dealing with transmission are closed source in the library.

Regards

Augusto

0 Kudos
1,328 Views
georgecapraru
NXP Employee
NXP Employee

Hi Augusto,

The functions dealing with the transmission are not closed. See the files from Phy\Source\:

    PhyPlmeData.c: PhyPdDataRequest() - start a new Tx

    PhyISR.c: PHY_InterruptHandler() - see the "gCCA_c", "gTX_c" and "gTR_c" switch cases for the end of a Tx

You can set/clear the GPIO2 (MCU pin #3) inside these functions.

Also, if you check the KW2x documentation (http://www.nxp.com/files/rf_if/doc/ref_manual/MKW2xDxxxRM.pdf?fpsp=1&WT_TYPE=Reference%20Manuals&WT_...)

you will find a "TX_SWITCH" (MCU pin #47) which is intended to be used with a Power Amplifier.

To enable the TX_SWITCH you have to configure the XCVR as shown below:

uint8_t reg = 1; /* Enable RX/TX_SWITCH */

//reg |= (4 << cANT_PAD_CTRL_ANTX_POL_Shift_c); /* Invert the TX_SWITCH output if needed */

MC1324xDrv_IndirectAccessSPIWrite(ANT_PAD_CTRL, reg);

Regards,

George

1,328 Views
augustosala
Contributor II

Hi George,

Unluckyly the hardware design is completed with the PA connected to GPIO2 so I should adapt the firmware now.

I checked the 2 functions you mentioned and inserted the GPIO handling there but I can't see the application accessing any of the two.

I'm sending raw data packats with Test Tool on a MAC 2003 project and I've set breakpoints at the beginning of each function without being stopped there even after multiple TX and RX. Also I checked with an oscilloscope if the gpio moves to exclude problems with the debugger but no, no reaction.

Regards

Augusto

0 Kudos
1,328 Views
georgecapraru
NXP Employee
NXP Employee

Hi Augusto,

If you are sending raw data packets from Test Tool, I'm guessing that you are using the "AspTelecSendRawData.Request" command.

The ASP module is intended to be used for XCVR testing, and is indeed part of the MAC library.

In this case you have to search for the call to the "void ASP_TelecSendRawData(uint8_t* dataPtr)" function, and enable the PA before this call.

Then, you have to wait for the Tx sequence to finish and then disable the PA. Here is an example:

    /* Enable the External PA */

    MC1324xDrv_SetGpioPin(gMC1324x_GPIO2_d);

    /* Most probably the ASP_TelecSendRawData function is called from the ZtcSAPHandlerInfo.c file */

    ASP_TelecSendRawData((uint8_t*)&pMsg->msgData.req.aspTelecSendRawData);

    /* Wait for the Sequence to end */

    while( !(MC1324xDrv_DirectAccessSPIRead(IRQSTS1) & cIRQSTS1_SEQIRQ)) {}

    /* Disable the External PA */

     MC1324xDrv_ClearGpioPin(gMC1324x_GPIO2_d);

Regards,

George

0 Kudos