2011-12-21 10:08 PM
I used the SSP sample code and enable SSP0 without loopback. I still get the transmitted dummy data when I send it for receving. After I test the sample code,I found that the GPIO setting cause this effect. I used p2.2 & p2.3 as slave I2C. When I set p2.3 GPIO_IPInputConnected_Disable, the SSP0 will function normal but slave I2C will fail. When I set p2.3 GPIO_IPInputConnected_Enable, the slave I2C function normal but SSP0 receive dummy data I send for receiving. I need slave I2C and SSP0 both on STR9. Please tell me how to solve it. Thanks.
GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_0 | GPIO_Pin_1); GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Type = GPIO_Type_OpenCollector; GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable; GPIO_InitStructure.GPIO_Alternate=GPIO_OutputAlt2; GPIO_Init(GPIO2, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_2 ); GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Type = GPIO_Type_OpenCollector; GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable; GPIO_InitStructure.GPIO_Alternate=GPIO_OutputAlt2; GPIO_Init(GPIO2, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_3); GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Type = GPIO_Type_OpenCollector; GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Disable;//make flash work normal but cause slave I2C abnormal GPIO_InitStructure.GPIO_Alternate=GPIO_OutputAlt2; GPIO_Init(GPIO2, &GPIO_InitStructure); /* Gonfigure SSP0_CLK, SSP0_MOSI */ GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2; GPIO_Init(GPIO2, &GPIO_InitStructure); /* Gonfigure SSP0_NSS pins */ GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_InitStructure.GPIO_Type = GPIO_Type_OpenCollector; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1; GPIO_Init(GPIO2, &GPIO_InitStructure); /* Gonfigure SSP0_MISO pin GPIO2.6 */ GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable; GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1 ; GPIO_Init(GPIO2, &GPIO_InitStructure); /* SSP0 configuration */ SSP_DeInit(SSP0); SSP_InitStructure.SSP_FrameFormat = SSP_FrameFormat_Motorola; SSP_InitStructure.SSP_Mode = SSP_Mode_Master; SSP_InitStructure.SSP_CPOL = SSP_CPOL_High; SSP_InitStructure.SSP_CPHA = SSP_CPHA_2Edge; SSP_InitStructure.SSP_DataSize = SSP_DataSize_8b; SSP_InitStructure.SSP_ClockRate = 0; SSP_InitStructure.SSP_ClockPrescaler = 2; SSP_Init(SSP0, &SSP_InitStructure); /* SSP0 enable */ SSP_LoopBackConfig(SSP0, DISABLE); SSP_Cmd(SSP0, ENABLE); #ssp