cancel
Showing results for 
Search instead for 
Did you mean: 

Triangle signal at the CCO Output (Port C4) / STM8S001JM3

ATürk.11
Associate II

Hi,

I generate 2 mhz from the PORT / PIN C4 (CCO).

The problem is that instead of a square signal, I get a triangle signal.

What could be the reason????

On PORT / PIN A3 i can generate a square signal, but not on C4

I Use the STM8-SO8-DISCO Board in which the STM8S001JM3 is installed

Here is the Code.:

#include "stm8s.h"
 
#include "stm8s_gpio.h"
 
#include "stm8s_clk.h"
 
 
 
#define GPIO_PORT    (GPIOA)
 
#define GPIO_PINS    (GPIO_PIN_3)
 
 
 
#ifdef _COSMIC_
 
 #define ASM _asm
 
#endif
 
 
 
#define STARTUP_SWIM_DELAY_5S \
 
 { \
 
 ASM(" PUSHW X \n" \
 
 " PUSH A \n" \
 
 " LDW X, #0xFFFF \n" \
 
 "loop1: LD A, #50 \n" \
 
 \
 
 "loop2: DEC A \n" \
 
 " JRNE loop2 \n" \
 
 \
 
 " DECW X \n" \
 
 " JRNE loop1 \n" \
 
 \
 
 " POP A \n" \
 
 " POPW X " ); \
 
 }
 
 
 
#define CONFIG_UNUSED_PINS_STM8S001 \
 
{ \
 
 GPIOA->DDR |= GPIO_PIN_2; \
 
 GPIOB->DDR |= GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_7; \
 
 GPIOC->DDR |= GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7; \
 
 GPIOD->DDR |= GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_7; \
 
 GPIOE->DDR |= GPIO_PIN_5; \
 
 GPIOF->DDR |= GPIO_PIN_4; \
 
}
 
 
 
 void GPIO_Config(void);
 
 void CLK_Config(void);
 
 
 
void main(void)
 
{
 
  CLK_Config();
 
 GPIO_Config();
 
   
 
 /* delay for SWIM connection: ~5seconds */
 
 STARTUP_SWIM_DELAY_5S; 
 
 /* configure unbonded pins */
 
 CONFIG_UNUSED_PINS_STM8S001;
 
	
 
 while(1)
 
  {
 
 GPIO_WriteLow(GPIOA,GPIO_PIN_3); // only for reading the frequency on another port
 
 
 
 GPIO_WriteHigh(GPIOA,GPIO_PIN_3);
 
  }
 
}
 
 
 
void GPIO_Config(void)
 
{
 
 GPIO_Init(GPIO_PORT,GPIO_PINS, GPIO_MODE_OUT_PP_LOW_FAST );
 
 GPIO_Init(GPIOC, GPIO_PIN_4, GPIO_MODE_OUT_PP_HIGH_FAST );
 
}
 
 
 
void CLK_Config(void)
 
{
 
  CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1);
 
  CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1); 
 
 CLK_CCOConfig(CLK_OUTPUT_CPU); 
 
  CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);
 
  CLK_CCOCmd(ENABLE);
 
 
 
}

         

2 REPLIES 2

Look at schematic. PC4 is connected to "user button" and bypassed by 100nF Capacitor (C12).

https://www.st.com/resource/en/user_manual/dm00462805-discovery-kit-with-stm8s001j3m3-stm8l001j3m3-and-stm8l050j3m3-mcus-stmicroelectronics.pdf

signal "STM8S001J3_USER_B"

ATürk.11
Associate II

thank you mdudka9,

i solved it last week, but thats is the correct answer !

thx again !