i am not understanding what is the problem with code??its giving error as
#error cpstm8 main.c:56(37) old style argument declaration
......how to write TIMER ISR in STM8S103???
/* MAIN.C file
*
* Copyright (c) 2002-2005 STMicroelectronics
*/
#include <iostm8s103.h>
#include "lib.h"
void setuptimer2(void);
void InitialiseSystemClock(void);
main()
{
PD_ODR=0;
PD_DDR=0X01;
PD_CR1=0X01;
PD_CR2=0X01;
TIM2_SR1=0X01;
InitialiseSystemClock();
setuptimer2();
TIM2_IER=0X40;
while (1)
{
while((TIM2_SR1 & 0X01)==0);
}
}
void InitialiseSystemClock(void)
{
//CLK_ICKR = 0X00; // Reset the Internal Clock Register.
//CLK_ICKR= CLK_ICKR|0X01; // Enable the HSI.
//CLK_ECKR = 0X00; // Disable the external clock.
// while ((CLK_ICKR&(0X02))==0); // Wait for the HSI to be ready for use.
CLK_CKDIVR = 0; // Ensure the clocks are running at full speed.
CLK_PCKENR1 = 0xff; // Enable all peripheral clocks.
CLK_PCKENR2 = 0xff; // Ditto.
CLK_CCOR = 0; // Turn off CCO.
CLK_HSITRIMR = 0; // Turn off any HSIU trimming.
CLK_SWIMCCR = 0; // Set SWIM to run at clock / 2.
CLK_SWR = 0xe1; // Use HSI as the clock source.
CLK_SWCR = 0; // Reset the clock switch control register.
CLK_SWCR=CLK_SWCR|0X02; // Enable switching.
while ((CLK_SWCR & 0X01) != 0); // Pause while the clock switch is busy.
}
void setuptimer2(void)
{
TIM2_PSCR=0X00;
TIM2_ARRH=0X01;
TIM2_ARRL=0XE0;
TIM2_IER=0X01;
TIM2_CR1=0X01;
}
//
// Timer 2 Overflow handler.
//
//#pragma vector = TIM2_OVR_UIF_vector
INTERRUPT_HANDLER(TIM2_UPD_OVF_IRQHandler)
{
unsigned char data;
PD_ODR=0X01;
data=PD_ODR;
PD_ODR=!data;
//data = PD_ODR_ODR4;
//PD_ODR_ODR4 = !data; // Toggle Port D, pin 5.
if (data == 1)
{
TIM2_IER = 0x01; // Only allow the pulse to happen once.
}
TIM2_SR1 = 0x01; // Reset the interrupt otherwise it will fire again straight away.
}
#error cpstm8 main.c:56(37) old style argument declaration
......how to write TIMER ISR in STM8S103???
/* MAIN.C file
*
* Copyright (c) 2002-2005 STMicroelectronics
*/
#include <iostm8s103.h>
#include "lib.h"
void setuptimer2(void);
void InitialiseSystemClock(void);
main()
{
PD_ODR=0;
PD_DDR=0X01;
PD_CR1=0X01;
PD_CR2=0X01;
TIM2_SR1=0X01;
InitialiseSystemClock();
setuptimer2();
TIM2_IER=0X40;
while (1)
{
while((TIM2_SR1 & 0X01)==0);
}
}
void InitialiseSystemClock(void)
{
//CLK_ICKR = 0X00; // Reset the Internal Clock Register.
//CLK_ICKR= CLK_ICKR|0X01; // Enable the HSI.
//CLK_ECKR = 0X00; // Disable the external clock.
// while ((CLK_ICKR&(0X02))==0); // Wait for the HSI to be ready for use.
CLK_CKDIVR = 0; // Ensure the clocks are running at full speed.
CLK_PCKENR1 = 0xff; // Enable all peripheral clocks.
CLK_PCKENR2 = 0xff; // Ditto.
CLK_CCOR = 0; // Turn off CCO.
CLK_HSITRIMR = 0; // Turn off any HSIU trimming.
CLK_SWIMCCR = 0; // Set SWIM to run at clock / 2.
CLK_SWR = 0xe1; // Use HSI as the clock source.
CLK_SWCR = 0; // Reset the clock switch control register.
CLK_SWCR=CLK_SWCR|0X02; // Enable switching.
while ((CLK_SWCR & 0X01) != 0); // Pause while the clock switch is busy.
}
void setuptimer2(void)
{
TIM2_PSCR=0X00;
TIM2_ARRH=0X01;
TIM2_ARRL=0XE0;
TIM2_IER=0X01;
TIM2_CR1=0X01;
}
//
// Timer 2 Overflow handler.
//
//#pragma vector = TIM2_OVR_UIF_vector
INTERRUPT_HANDLER(TIM2_UPD_OVF_IRQHandler)
{
unsigned char data;
PD_ODR=0X01;
data=PD_ODR;
PD_ODR=!data;
//data = PD_ODR_ODR4;
//PD_ODR_ODR4 = !data; // Toggle Port D, pin 5.
if (data == 1)
{
TIM2_IER = 0x01; // Only allow the pulse to happen once.
}
TIM2_SR1 = 0x01; // Reset the interrupt otherwise it will fire again straight away.
}