Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

STM8S103 read port issue

Status
Not open for further replies.

radioratiometrics

New Member
Hi I am using an STM8S103F3 and using ST standard peripheral library for STM8 and using an STM8S103F3 mini dev board. I am currently unable to read any input pin the GPIO_ReadInputPin function is not returning me any value. Neither the BitStatus SET or RESET is returned.However when i set the pin to output i can toggle them to any value i want. Below is my code. I first tried with pins A1 and A2 then B5 and then C3 but with no success. In case anyone can please help that would be great thanks

#include "stm8s.h"
#include "stm8s_conf.h"



#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

/* Infinite loop */
while (1)
{
}
}
#endif


void main(void)
{

CLK_DeInit();
CLK_HSICmd(ENABLE);
CLK_LSICmd(DISABLE);
CLK_HSECmd(DISABLE);
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1 );


GPIO_DeInit(GPIOB);
GPIO_DeInit(GPIOC);

GPIO_Init(GPIOC,GPIO_PIN_3,GPIO_MODE_IN_PU_NO_IT );
GPIO_Init(GPIOB,GPIO_PIN_5,GPIO_MODE_OUT_PP_LOW_FAST);



GPIO_WriteHigh(GPIOB,GPIO_PIN_5);

while(1)
{
if(GPIO_ReadInputPin(GPIOC,GPIO_PIN_3)==SET)
{
GPIO_WriteLow(GPIOB,GPIO_PIN_5);
}

else if(GPIO_ReadInputPin(GPIOC,GPIO_PIN_3)==RESET)
{
GPIO_WriteHigh(GPIOB,GPIO_PIN_5);
}
}
 
Status
Not open for further replies.

Latest threads

Back
Top