在线时间0 小时
UID3109951
ST金币0
蝴蝶豆0
注册时间2015-3-24
新手上路
- 最后登录
- 2015-3-25
|
发表于 2015-3-25 12:02:17
|
显示全部楼层
a0a.1 0b0c
main.c:
#include "stm8s103f2u.h"
//int a,b,c;
void initLED(void);
void initTIM4(void);
/*void delay_10us(int us);
void delay_ms(unsigned int ms);*/
@far @interrupt void TIM4light(void);
main()
{
initLED();
initTIM4();
_asm("rim");
TIM4_CR1|=0x01;
while (1){
}
}
void initLED(void){
PC_DDR=0x70;
PC_CR1=~0x70;
PC_CR2=~0x70;
// PC_ODR=0x70;
}
void initTIM4(void){
TIM4_PSCR=0x07;
TIM4_IER=0x01;
TIM4_CNTR=255;
TIM4_ARR=255;
}
中断向量表:
/* BASIC INTERRUPT VECTOR TABLE FOR STM8 devices
* Copyright (c) 2007 STMicroelectronics
*/
#include "stm8s103f2u.h"
int i;
typedef void @far (*interrupt_handler_t)(void);
struct interrupt_vector {
unsigned char interrupt_instruction;
interrupt_handler_t interrupt_handler;
};
@far @interrupt void NonHandledInterrupt (void)
{
return;
}
@far @interrupt void TIM4light (void)
{
i++;
if(i==61)
{ i=0;
if(PC_ODR==0x70)
{
PC_ODR=~0x70;
}
else
{
PC_ODR=0x70;
}
}
TIM4_SR=0x00;
return;
}
extern void _stext(); /* startup routine */
struct interrupt_vector const _vectab[] = {
{0x82, (interrupt_handler_t)_stext}, /* reset */
{0x82, NonHandledInterrupt}, /* trap */
{0x82, NonHandledInterrupt}, /* irq0 */
{0x82, NonHandledInterrupt}, /* irq1 */
{0x82, NonHandledInterrupt}, /* irq2 */
{0x82, NonHandledInterrupt}, /* irq3 */
{0x82, NonHandledInterrupt}, /* irq4 */
{0x82, NonHandledInterrupt}, /* irq5 */
{0x82, NonHandledInterrupt}, /* irq6 */
{0x82, NonHandledInterrupt}, /* irq7 */
{0x82, NonHandledInterrupt}, /* irq8 */
{0x82, NonHandledInterrupt}, /* irq9 */
{0x82, NonHandledInterrupt}, /* irq10 */
{0x82, NonHandledInterrupt}, /* irq11 */
{0x82, NonHandledInterrupt}, /* irq12 */
{0x82, NonHandledInterrupt}, /* irq13 */
{0x82, NonHandledInterrupt}, /* irq14 */
{0x82, NonHandledInterrupt}, /* irq15 */
{0x82, NonHandledInterrupt}, /* irq16 */
{0x82, NonHandledInterrupt}, /* irq17 */
{0x82, NonHandledInterrupt}, /* irq18 */
{0x82, NonHandledInterrupt}, /* irq19 */
{0x82, NonHandledInterrupt}, /* irq20 */
{0x82, NonHandledInterrupt}, /* irq21 */
{0x82, NonHandledInterrupt}, /* irq22 */
{0x82, TIM4light}, /* irq23 */
{0x82, NonHandledInterrupt}, /* irq24 */
{0x82, NonHandledInterrupt}, /* irq25 */
{0x82, NonHandledInterrupt}, /* irq26 */
{0x82, NonHandledInterrupt}, /* irq27 */
{0x82, NonHandledInterrupt}, /* irq28 */
{0x82, NonHandledInterrupt}, /* irq29 */
};
我的也进入不了中断,求大神!
|
|