SparkFun Forums 

Where electronics enthusiasts find answers.

Everything with the AmbiqSuite SDK tools and software are welcome here.
User avatar
By txmoa
#231154
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!
By paulvha
#231160
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.
By paulvha
#231161
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);
User avatar
By txmoa
#231162
paulvha wrote: Wed Feb 02, 2022 10:07 am 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?
By paulvha
#231163
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.
User avatar
By txmoa
#231165
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..
 Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum