AnsweredAssumed Answered

How can I set the CS signal for spi with _io_ctl()?

Question asked by projektecarus on Mar 25, 2014
Latest reply on Apr 4, 2014 by soledad

Hi everybody,

 

I'm using a K60F120M Tower with MQX 4.0.2. I tried to set the CS signal for spi2 to SPI2_CS0/1 with the _io_ctl()-command.

 

The code looks like this:

...

MQX_FILE_PTR mcp23s17_SPI;

uint_32 mcp23s17_CS = SPI_PUSHR_PCS(1 << 0);     // Chip-Select-Mask for SPI2_CS0

 

mcp23s17_SPI = _io_fopen("spi2:", NULL);

_io_ioctl(mcp23s17_SPI, IO_IOCTL_SPI_SET_CS, &mcp23s17_CS);

...

_io_write(mcp23s17_SPI,...);

_io_fflush(mcp23s17_SPI);

...

 

The BSPCFG_ENABLE_SPI2 is set in user_config.h and the return value of _io_fopen isn't NULL. The return value of _io_ctl() is SPI_OK.

 

If I measure the CS-signal it is always on high, although the MOSI and the CLK signals are OK.

If I don't try to change the standard settings the CS signal works.

 

Thanks for any help on this problem.

Outcomes