cancel
Showing results for 
Search instead for 
Did you mean: 

Pins on STM8S001J3 no ouput...

MQi.1
Senior II

I tried this code on STM8S001J3 with 8 pins:

/* MAIN.C file
 * 
 * Copyright (c) 2002-2005 STMicroelectronics
 */
//#include “stm8s.h�? 
 
/*main()
{
	while (1);
}
*/
 
#include "STM8S.h"
 
void clock_setup(void);
void GPIO_setup(void);
void TIM1_setup(void);
 
void delaySomeTime(void);
 
 
void main(void)
{
     //signed int i = 0;
     clock_setup();
     GPIO_setup();
     //TIM1_setup();
		 
     while(TRUE)
     {
          GPIO_WriteReverse(GPIOB,GPIO_PIN_4);
					GPIO_WriteLow(GPIOB,GPIO_PIN_5);
					GPIO_WriteLow(GPIOC,GPIO_PIN_5);
					GPIO_WriteLow(GPIOD,GPIO_PIN_6);
					delaySomeTime();
					
					GPIO_WriteReverse(GPIOB,GPIO_PIN_4);
					GPIO_WriteHigh(GPIOB,GPIO_PIN_5);
					GPIO_WriteHigh(GPIOC,GPIO_PIN_5);
					GPIO_WriteHigh(GPIOD,GPIO_PIN_6);
					delaySomeTime();
          }
}
 
void delaySomeTime(void){
	
	int i = 0;
  int j = 0;
	
	for(i = 0; i < 100; i++){
		for(j = 0; j < 100; j++){
			//;
			_asm("nop"); //Perform no operation //assembly code
		}
	}
}
 
void GPIO_setup(void)
{                               
     GPIO_DeInit(GPIOB);
     GPIO_Init(GPIOB, GPIO_PIN_4, GPIO_MODE_OUT_PP_HIGH_FAST);
		 GPIO_Init(GPIOB, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST);
                
     GPIO_DeInit(GPIOC);
     GPIO_Init(GPIOC, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST);
		 
		 GPIO_DeInit(GPIOD);
     GPIO_Init(GPIOD, GPIO_PIN_6, GPIO_MODE_OUT_PP_HIGH_FAST);
}
 
void clock_setup(void)
{
     CLK_DeInit();
     CLK_HSECmd(DISABLE);
     CLK_LSICmd(DISABLE);
     CLK_HSICmd(ENABLE);
 
     while(CLK_GetFlagStatus(CLK_FLAG_HSIRDY) == FALSE);
 
     CLK_ClockSwitchCmd(ENABLE);
     CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
     CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1);
		 
     CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI, DISABLE, CLK_CURRENTCLOCKSTATE_ENABLE);
		 
     CLK_PeripheralClockConfig(CLK_PERIPHERAL_I2C, DISABLE);
     CLK_PeripheralClockConfig(CLK_PERIPHERAL_SPI, DISABLE);
     CLK_PeripheralClockConfig(CLK_PERIPHERAL_ADC, DISABLE);
     CLK_PeripheralClockConfig(CLK_PERIPHERAL_AWU, DISABLE);
     CLK_PeripheralClockConfig(CLK_PERIPHERAL_UART1, DISABLE);          
     CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER1, ENABLE);
     CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER2, DISABLE);
     CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER4, DISABLE);
}
 
 
/*void TIM1_setup(void)
{
     TIM1_DeInit();
     TIM1_TimeBaseInit(16, TIM1_COUNTERMODE_UP, 1000, 1);
		 
     TIM1_OC1Init(TIM1_OCMODE_PWM1, 
									TIM1_OUTPUTSTATE_ENABLE, 
									TIM1_OUTPUTNSTATE_ENABLE, 
									1000, 
									TIM1_OCPOLARITY_LOW, 
                  TIM1_OCNPOLARITY_LOW, 
                  TIM1_OCIDLESTATE_RESET, 
                  TIM1_OCNIDLESTATE_RESET);                
 
    TIM1_CtrlPWMOutputs(ENABLE);
    TIM1_Cmd(ENABLE);
}*/

while, the LEDs didn't blink as it were expected, why? (I used SPL in STVD and programmed in STVP by ST-Link V2.)

3 REPLIES 3
MQi.1
Senior II

I used SPL in STVD and programmed in STVP by ST-Link V2.

Cristian Gyorgy
Senior III

I don't comment on your code, but how do you expect the LEDs to blink? How do you test if it works?

Do you expect to see a blinking with the eye?

Your delaySomeTime() function would take around 2,5 ms - you cannot see this with the bare eye.

I set "i < 1000" and "j < 1000" before, it was the same.