changing polarization of chip select

Hello, For my device, CS is active high, and the default CS pin behavior is active low. I am using IOM0 and tried to change line 244 in am_bsp_pins.c to the following

const am_hal_gpio_pincfg_t g_AM_BSP_GPIO_IOM0_CS =

{

.uFuncSel = AM_HAL_PIN_11_NCE11,

.eDriveStrength = AM_HAL_GPIO_PIN_DRIVESTRENGTH_12MA,

.eGPOutcfg = AM_HAL_GPIO_PIN_OUTCFG_PUSHPULL,

.eGPInput = AM_HAL_GPIO_PIN_INPUT_NONE,

.eIntDir = AM_HAL_GPIO_PIN_INTDIR_LO2HI,

.bIomMSPIn = 1,

.uIOMnum = 0,

.uNCE = 0,

.eCEpol = AM_HAL_GPIO_PIN_CEPOL_ACTIVEHIGH

};

However, when I probe GPIO11, (as well as the SCLK AND SDI), the clock and data lines look correct, however, I couldn’t for my life change the CS line to be active high…help is much appreciated!

Which library version do you use and which board?

I tried both the 2.5.1 and the latest sparkfun version of SDK, the board is 3p_evb

The Sparkfun version V2.xx will need a recompile of the pre-compiled MBED library before any change that is made in cores/mbed-os folders is applied. Have not looked at 2.5.1. yet. Maybe try Sparkfun version 1.2.3 to see what happens.

If you have enough pins you can define your own CS-PIN.:

#define CS_PIN 2

// init

digitalWrite(CS_PIN, LOW)

pinMode(CS_PIN, OUTPUT);

before SPI.beginTransaction() you do

digitalWrite(CS_PIN, HIGH);

After SPI.endTransaction() you do

digitalWrite(CS_PIN, LOW);

paulvha:
The Sparkfun version V2.xx will need a recompile of the pre-compiled MBED library before any change that is made in cores/mbed-os folders is applied. Have not looked at 2.5.1. yet. Maybe try Sparkfun version 1.2.3 to see what happens.

Ooooh, wasn’t aware of that at all…Could you point me to how to go about doing this? Is there an easy way to do this on Windows with Keil by any chance?

Hi

Actually, that is a bit of a process. Maybe faster to follow my latest advice and define your own pin and forget the rest.

Tried to include the complete description but it did not allow me (error 402) to send before. drop me a mail on paulvha@hotmail.com and I can send it

ok, thanks! Actually I found another workaround after you pointed out the problem.

const am_hal_gpio_pincfg_t test =

{

.uFuncSel = AM_HAL_PIN_11_NCE11,

.eDriveStrength = AM_HAL_GPIO_PIN_DRIVESTRENGTH_12MA,

.eGPOutcfg = AM_HAL_GPIO_PIN_OUTCFG_PUSHPULL,

.eGPInput = AM_HAL_GPIO_PIN_INPUT_NONE,

.eIntDir = AM_HAL_GPIO_PIN_INTDIR_LO2HI,

.bIomMSPIn = 1,

.uIOMnum = 0,

.uNCE = 0,

.eCEpol = AM_HAL_GPIO_PIN_CEPOL_ACTIVEHIGH

};

am_hal_gpio_pinconfig(AM_BSP_GPIO_IOM0_CS, test);

Well, in case this happened to someone else…

even better :slight_smile:

Thank you very much for your help! Much appreciated =)