2016-04-05 06:26 AM
First i'm sorry for my bad in english
i have 2 problem for STVD+COSMIC
/**-------------------
first question
-------------------- **/
#include
''stm8s103k.h''
int main(void)
{ CLK_CKDIVR = 0; // prescaler system clock = 1 while( (CLK_ICKR & 2)==0 ); // wait HSI ready TIM1_ARR = 1600 - 1; // auto reload 100 usec TIM1_CR1 = 1; // enable timer_1 PB_DDR |= 1<<3; // o/p.. pin_B3 PB_CR1 |= 1<<3; // push_pull while (1){ if( TIM1_SR1 & 1 ){ TIM1_SR1 &= ~1; PB_ODR ^= 1<<3; } }}This code.. TIM1_CNTR can not over flow by TIM1_ARR's value (1599)
TIM1 counting to 0xFFFF and over flow
But this code can overflow and reload with TIM1_ARR's value (1599 = 0x0639)
Output pulse of ODR_B No3 is 5kHz.. which is valid(with IAR.. i edit TIM1_ARR to..
TIM1_ARRH=0x06; TIM1_ARRL=0x39;)What i missing coding..?
/**-------------------
second question
-------------------- **/#include ''stm8s103k.h''
void system_config ( ){CLK_CKDIVR = 0;
// prescaler system clock = 1
while( (CLK_ICKR & 2)==0 );
// wait HSI ready
TIM1_ARR
= 1600 - 1;
// auto reload 100 usec
TIM1_CR1
= 1;
// enable timer_1
}int main(void)
{system_config ( ) ;
PB_DDR |= 1<<3; // o/p.. pin_B3 PB_CR1 |= 1<<3; // push_pull while (1){ if( TIM1_SR1 & 1 ){ TIM1_SR1 &= ~1; PB_ODR ^= 1<<3; } }}when rebuild all...Compiling main.c...
cxstm8 -i''c:\program files\stmicroelectronics\st_toolset\include''\
+mods0 +debug -pxp -no -pp -l -i''C:\Program Files\COSMIC\FSE_Compilers\
CXSTM8\Hstm8'' -clDebug\ -coDebug\ main.c
#error cpstm8 main.c:11(15) missing prototype
main.c:
The command: ''cxstm8 -i''c:\program files\stmicroelectronics\
st_toolset\include'' +mods0 +debug -pxp -no -pp -l -i''C:\Program Files\
COSMIC\FSE_Compilers\CXSTM8\Hstm8'' -clDebug\ -coDebug\
main.c'' has failed, the returned value is: 1
exit
code=1.
line : system_config() in main(void)
But this code can complier and debug in IAR_for_STM8
with output pulse 5kHz ODR_B3
How do i solve this problem
i am very confuse. @_@!
Thank you very much for answer.
Sorry for my bad in English again
^_^!
/*******************************************/Now i can solve this problemThank youLiem HUA.. of
htl@cosmic.fr
2-way for fix :1. remove -pp option of complier of STVD tab : Project -> Setting -> C_Complier -> C_Language Change_setting from Enforce_Function_Prototyping -> Default2. change Prototype(){ /* code */ } .. (old of my) toPrototype(void){ /* code*/ }
^_^!2016-04-05 11:33 PM