2013-11-23 02:09 PM
I know this is weird, but any help would be great. This is driving me nuts.
I'm tyring to use A5, A6 and A7 as SPI for communication with a touchscreen controller. SCLK and MOSI work fine, but MISO (A6) works only the first time and then becomes active high thereafter? What could cause this? I have included the configuration code. Thanks,// enable clock for used IO pins
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,
ENABLE
);/* configure pins used by SPI1
* PA5 = SCK
* PA6 = MISO
* PA7 = MOSI
*/
GPIO_InitStruct.
GPIO_Pin
= GPIO_Pin_7 | GPIO_Pin_6 | GPIO_Pin_5;GPIO_InitStruct.
GPIO_Mode
=
GPIO_Mode_AF
;GPIO_InitStruct.
GPIO_OType
=
GPIO_OType_PP
;GPIO_InitStruct.
GPIO_Speed
=
GPIO_Speed_25MHz
;GPIO_InitStruct.
GPIO_PuPd
=
GPIO_PuPd_UP
;GPIO_Init(GPIOA, &GPIO_InitStruct);
// connect SPI1 pins to SPI alternate function
GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_SPI1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_SPI1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_SPI1);
#spi2013-11-23 06:28 PM
I know this is weird, but any help would be great. This is driving me nuts. I'm tyring to use A5, A6 and A7 as SPI for communication with a touchscreen controller. SCLK and MOSI work fine, but MISO (A6) works only the first time and then becomes active high thereafter?
You're asking the wrong question. The STM32 in this equation is presumably the MASTER, the pin you're complaining about is driven by the SLAVE device. The question should revolve around the slave device, what it is, what your sending to it to configure it, and how and what you expect it to communicate back to you. Is there an expectation of a chip select? Is the data you are sending actually received and acted upon?2013-11-24 01:54 AM
2013-11-24 04:40 AM
Once you have configured a pin in AF mode the peripheral behind it controls the pin state and direction. What and how the pin behaves will then be determined by how you have configured the peripheral and what you do with it, and this code is absent.
Perhaps you are setting it up as a slave or something on the STM32 end, or that in sending data to the slave in your first communication you are misconfiguring the slave. Again things I can't know with the code presented, and documentation for the slave cited. In order to troubleshoot this remotely you are going to need to reformulate how you describe the problem to include a code example that is complete and demonstrative of the problem you are having, and which provided detail of the slave device you are communicating with, and documentation that explains it's connectivity information and command/response expectations.