xp1314520 发表于 2013-3-30 00:32
你好,halt();进入睡眠模式,但是放在哪个位置呢?唤醒语句又放在哪个位置啊?求指教 ...
呵呵,halt()放在任务处理完后;也就是main里的while这个超级循环内,
STM8S103支持IO的中断唤醒,在中断文件(stm8_interrupt_vector.c)里做中断设置:
struct interrupt_vector const _vectab[] = {
{0x82, (interrupt_handler_t)_stext}, /* reset */
{0x82, NonHandledInterrupt}, /* trap */
{0x82, NonHandledInterrupt}, /* irq0 External top level interrupt*/
{0x82, NonHandledInterrupt}, /* irq1 Auto wake up from halt*/
{0x82, NonHandledInterrupt}, /* irq2 Clock controller*/
{0x82, PA3_Exit_Int_Isr }, /* irq3 Port A external interrupts*/
{0x82, NonHandledInterrupt}, /* irq4 Port B external interrupts*/
{0x82, NonHandledInterrupt}, /* irq5 Port C external interrupts*/
{0x82, NonHandledInterrupt}, /* irq6 Port D external interrupts*/
{0x82, NonHandledInterrupt}, /* irq7 Port E external interrupts*/
{0x82, NonHandledInterrupt}, /* irq8 Reserved*/
{0x82, NonHandledInterrupt}, /* irq9 Reserved*/
{0x82, NonHandledInterrupt}, /* irq10 SPI End of transfer*/
{0x82, NonHandledInterrupt}, /* irq11 TIM1 update/ overflow/ underflow/trigger/ break*/
{0x82, NonHandledInterrupt}, /* irq12 TIM1 capture/ compare*/
{0x82, NonHandledInterrupt}, /* irq13 TIM2 update/ overflow*/
{0x82, NonHandledInterrupt}, /* irq14 TIM2 capture/ compare*/
{0x82, NonHandledInterrupt}, /* irq15 Reserved*/
{0x82, NonHandledInterrupt}, /* irq16 Reserved*/
{0x82, NonHandledInterrupt}, /* irq17 UART1 Tx complete*/
{0x82, NonHandledInterrupt}, /* irq18 UART1 Receive register DATA FULL*/
{0x82, NonHandledInterrupt}, /* irq19 I2C interrupt*/
{0x82, NonHandledInterrupt}, /* irq20 Reserved*/
{0x82, NonHandledInterrupt}, /* irq21 Reserved*/
{0x82, NonHandledInterrupt}, /* irq22 ADC1 end of conversion/ analog watchdog interrupt*/
{0x82, NonHandledInterrupt}, /* irq23 TIM4 update/ overflow*/
{0x82, NonHandledInterrupt}, /* irq24 EOP/WR_PG_DIS*/
{0x82, NonHandledInterrupt}, /* irq25 Reserved*/
{0x82, NonHandledInterrupt}, /* irq26 Reserved*/
{0x82, NonHandledInterrupt}, /* irq27 Reserved*/
{0x82, NonHandledInterrupt}, /* irq28 Reserved*/
{0x82, NonHandledInterrupt}, /* irq29 Reserved*/
};
中断函数如下:
@far @interrupt void PA3_Exit_Int_Isr (void)
{
// ADD TASK CODE HERE
} |