programming stm8s103

Install ST visual Develop
install STM8S_StdPeriph_Driver

create file with following code (after —– till net —-)
copy stm8s_conf from STM8S_StdPeriph_Lib\Project\STM8S_StdPeriph_Template directory to your source directory
download adn install cosmic then

set cosmic path e.g. C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8 under project->setting ->general ->rootpath and toolset as “STM8 COSMIC”

Now complie and full build should work


#define STM8S103
#include "stm8s.h"

void myDelay(int k);

void myDelay(int k)
{
int i,j;
for(i=0;iDDR |=0x20;// PB.5 as Output
GPIOB->CR1 |=0x20;// PB.5 as Push Pull Type Output

/* Infinite loop */
while (1)
{
GPIOB->ODR |=1<<5;// PB.5 = 1 OFF myDelay(5000); GPIOB->ODR &=~(1<<5);// PB.5 = 0 ON myDelay(500); GPIOB->ODR |=1<<5;// PB.5 = 1 OFF myDelay(500); GPIOB->ODR &=~(1<<5);// PB.5 = 0 ON myDelay(500); GPIOB->ODR |=1<<5;// PB.5 = 1 OFF myDelay(2000); GPIOB->ODR &=~(1<<5);// PB.5 = 0 ON myDelay(500); GPIOB->ODR |=1<<5;// PB.5 = 1 OFF myDelay(500); GPIOB->ODR &=~(1<<5);// PB.5 = 0 ON myDelay(500); GPIOB->ODR |=1<<5;// PB.5 = 1 OFF myDelay(500); GPIOB->ODR &=~(1<<5);// PB.5 = 0 ON myDelay(500); GPIOB->ODR |=1<<5;// PB.5 = 1 OFF myDelay(500); GPIOB->ODR &=~(1<<5);// PB.5 = 0 ON myDelay(500); // myDelay(5000); } } #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(u8* file, u32 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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.