cancel
Showing results for 
Search instead for 
Did you mean: 

[solved]Problem: SPI1 doesn't work (no activity on SCK, MOSI)

jbolting9
Associate II
Posted on January 17, 2010 at 19:54

[solved]Problem: SPI1 doesn't work (no activity on SCK, MOSI)

4 REPLIES 4
jbolting9
Associate II
Posted on May 17, 2011 at 13:38

Hello everyone,

in order to communicate with a EADOGM128-64 LCD-display, I set up the SPI1 interface of my STM32. Nevertheless there is no clock signal on the SCK pin and no data signal on the MOSI pin while I am sending bytes. Any idea where I'm going wrong?

MOSI and SCK are configured as alternate function push-pull.

controller: STM32F103-RBT6 on STM32-H103 board by olimex

toolchain: codesourcery arm-2009q1-161-arm-none-eabi

initialization routine:

void SPI1_Init()

{

SPI1_ClkInit(); //enable SPI1 clock

SPI1_I2SCFGR = 0; //set to default; enable SPI mode

SPI1_CR1 = 0; //set to default

SPI1_CR1 |= (BIT5 | BIT3); //set baudrate to fpclk/64

SPI1_CR1 |= BIT0; //data capture on second SCLK transition

SPI1_CR1 |= BIT2; //Master mode

SPI1_CR1 |= BIT1; //SPI1_SCLK = high when idle

SPI1_CR1 |= BIT9; //enable NSS software mode

SPI1_CR1 |= BIT6; //enable SPI1

return;

}

enable SPI1 clock:

void SPI1_ClkInit(void)

{

RCC_APB2ENR |= BIT12; //enable SPI1 clock

return;

}

function to send data:

void SPI1_SendByte(u8 databyte)

{

SPI1_DR = (u16)databyte;

return;

}

best regards,

jan

[ This message was edited by: j.bolting on 18-01-2010 00:22 ]

16-32micros
Associate III
Posted on May 17, 2011 at 13:38

Dear Jan,

You forgot to enable the I/Os mapped to SCK, MOSI as ''alternate function'' Push-pull . Once enabled you will see your frame out.

Cheers,

STOne-32.

[ This message was edited by: STOne-32 on 14-01-2010 21:16 ]

jbolting9
Associate II
Posted on May 17, 2011 at 13:38

Hi,

the GPIO clocks are enabled by an initialization routine not documented in my posting; both ports (GPIO_A and GPIO_C) are successfully used for USART transmissions.

regards,

Jan

[ This message was edited by: j.bolting on 15-01-2010 19:57 ]

[ This message was edited by: j.bolting on 15-01-2010 19:58 ]

jbolting9
Associate II
Posted on May 17, 2011 at 13:38

Hello,

I had to set the SSI bit in the SPI1_CR1 Register. Now it works as expected.

But I'm still working on why that was the reason.

cheers,

jan

[ This message was edited by: j.bolting on 18-01-2010 00:35 ]