We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Heya guys,
Does anyoane know where can I get the initial project/script that runs on the board when you firt get it? I have a STM32F105RC.
I've been trying to use SPI1 to read data from DW1000-didn't work. I've tried to use SPI2 to initialise and write on the LCS Display(EA dog-m162A)--couldn't do it.
I have two boards and I have used just one of them, so the other one still has the initial program running, and both SPI buses work, as it light a LED commanded by DW1000 and Displays some text on the Display.
I couldn't find the right way to initialise the SPI bus and I think that's where my error is.
Any piece of advice would be great! Thank you very much!
Here is the code i'm using for the SPI...please tell me what i'm doing wrong!
#include "stm32f10x.h" // Device header #include "stm32f10x_gpio.h" #include "stm32f10x_spi.h" void SPI_SendData_8bits(SPI_TypeDef* SPIx, uint8_t Data) { /* Check the parameters */ assert_param(IS_SPI_ALL_PERIPH(SPIx)); /* Write in the DR register the data to be sent */ SPIx->DR = Data; } void send_data(uint8_t val) { GPIOB->BRR= (1<<11); //RS --LOW GPIOB->BRR= (1<<10); //RW---LOW GPIO_SetBits(GPIOB, GPIO_Pin_12); // NSS---HIGH delay(80000); GPIO_ResetBits(GPIOB, GPIO_Pin_12);//NSS LOW delay(800000); SPI_SendData_8bits(SPI2, val); while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET); //wait finish sending GPIO_SetBits(GPIOB, GPIO_Pin_12); // NSShigh GPIOB->BSRR= (1<<11); //RS high GPIOB->BSRR= (1<<10);//RW high } int main(void) { RCC->APB2ENR = RCC_APB2ENR_IOPBEN; // enable PORTB GPIOB->CRH =0x70777700;//for open drain---also tried in push-pull mode GPIOB->CRL =0;//570425344; SPI_I2S_DeInit(SPI2); /* Enable SCK, MOSI and MISO GPIO clocks */ RCC_AHBPeriphClockCmd(RCC_APB2Periph_GPIOB , ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE); RCC->APB1ENR = RCC_APB1ENR_SPI2EN; SPI2->CR1 = 0xC14F;//0b 1100000101001111; SPI2->CR1=SPI_CR1_SPE ;/not sure still neccessary SPI2->CR2=4; SPI_Cmd(SPI2, ENABLE); GPIOB->BRR= (1<<10); /* SPI_I2S_SendData( SPI2,0x39 ); delay(800000); SPI_I2S_SendData( SPI2,0x14 ); delay(800000); SPI_I2S_SendData( SPI2,0x55 ); delay(800000); SPI_I2S_SendData( SPI2,0x6d ); delay(800000); SPI_I2S_SendData( SPI2,0x78 ); delay(800000); SPI_I2S_SendData( SPI2,0x0f ); delay(800000); SPI_I2S_SendData( SPI2,0x01 ); delay(800000); SPI_I2S_SendData( SPI2,0x06 ); delay(800000); SPI_I2S_SendData( SPI2,0x39 ); delay(800000);*/ //-------Display's Initialisation----------- // I think it doesn't send anything!!! send_data(0x39); delay(800000); send_data(0x14); delay(800000); send_data(0x55); delay(800000); send_data(0x6d); delay(800000); send_data(0x78); delay(800000); send_data(0x38); delay(800000); send_data(0x0f); delay(800000); send_data(0x01); delay(800000); send_data(0x06); delay(800000); }
C'mon, people! Please? Is the code THAT wrong that you're not bothering? :))