2020-06-13 12:14 PM
Hello,
I am practicing with nucleof767ZI. I have stuck with the SPI, here i am trying to send some dummy data and read it through an analyzer. What I get is MOSI always low and SCK is always high. I find no change or pulses in clock line. As of now nothing is connected to these pins. Code as follows,
void tempInit(void){
RCC->CFGR = 0x0000D40A;
RCC->AHB1ENR |= (1U << 0);//Enabling Port-A clock
RCC->AHB1ENR |= (1U << 3);//Enabling Port-D clock
RCC->APB2ENR |= (1U << 12);//Enabling SPI-1 clock
GPIOA->MODER |= (0x10 << 5*2);//Port-A Pin- 5 SPI_SCK
GPIOA->MODER |= (0x10 << 7*2);//Port-A Pin- 7 SPI_MOSI
GPIOD->MODER |= (0x01 << 14*2);//Port-D Pin-14 SPI_SS
GPIOA->AFR[0] = 0x50500000;
GPIOA->AFR[1] = 0x00000000;
SPI1->CR2 = 0x170C;
SPI1->CR1 = 0xC33C;
SPI1->CR1 |= 0x0040;
SPI1_SS_Clear;
while(1){
SPI1->DR = 0x00AA;
}
SPI1->CR1 &= 0xFFBF;
}
This function is called directly from main after clock configuration. I know i am doing some mistake unable to find it out. Please help.
Thanks.
Solved! Go to Solution.
2020-06-13 07:29 PM
> GPIOA->MODER |= (0x10 << 5*2);//Port-A Pin- 5 SPI_SCK
Sure you meant 0x10 here? And not 0b10? Same for the other two lines after it.
2020-06-13 07:29 PM
> GPIOA->MODER |= (0x10 << 5*2);//Port-A Pin- 5 SPI_SCK
Sure you meant 0x10 here? And not 0b10? Same for the other two lines after it.
2020-06-13 09:01 PM
Thanks a lot TDK. I know i am doing a silly mistake, it needed a second eye to find it out. Solved.
Thanks again