打印

STR710 XTI Problem

[复制链接]
2695|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
Alex.Ron|  楼主 | 2011-5-28 13:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
eCos Pro2.0,STR710
DI0 is maped as CYGNUM_HAL_INTERRUPT_PORT_2_8
DI1 is maped as CYGNUM_HAL_INTERRUPT_PORT_2_9
Description:
1.Active status :“High”:
  a.The status of DI0 is "LOW" before device sleep.
When I Push DI0 UP, device wakeup.
  b.The status of DI0 is "HIGH" before device sleep.
      When I Push DI0 DOWN, device keep sleep status.
2.Active status :“Low”:
  a.The status of DI0 is "LOW" before device sleep.
      When I Push DI0 UP, device wakeup(ERROR).

  b.The status of DI0 is "HIGH" before device sleep.
     When I Push DI0 DOWN, device wakeup.
Problem:
The ERROR should not occur.
Here is my pieces of codes(DI0:Act as LOW,DI1:Act as HIGH):
#define CYGNUM_HAL_INTERRUPT_XTI_BASE                           32
#define CYGNUM_HAL_INTERRUPT_SOFTWARE                           (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 0)
#define CYGNUM_HAL_INTERRUPT_USB_WAKEUP                         (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 1)
#define CYGNUM_HAL_INTERRUPT_PORT_2_8                           (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 2)
#define CYGNUM_HAL_INTERRUPT_PORT_2_9                           (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 3)
#define CYGNUM_HAL_INTERRUPT_PORT_2_10                          (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 4)
....
#define CYGNUM_HAL_INTERRUPT_PORT_1_13                          (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 7)
#define CYGNUM_HAL_INTERRUPT_HCLK                               (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 7)
#define CYGNUM_HAL_INTERRUPT_I2C0_SCL                           (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 7)
#define CYGNUM_HAL_INTERRUPT_PORT_1_14                          (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 8)
#define CYGNUM_HAL_INTERRUPT_HDRX                               (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 8)
#define CYGNUM_HAL_INTERRUPT_I2C0_SDA                           (CYGNUM_HAL_INTERRUPT_XTI_BASE+ 8)
....
#define CYGNUM_HAL_INTERRUPT_PORT_0_2                           (CYGNUM_HAL_INTERRUPT_XTI_BASE+10)
#define CYGNUM_HAL_INTERRUPT_SPI0_SCLK                          (CYGNUM_HAL_INTERRUPT_XTI_BASE+10)
#define CYGNUM_HAL_INTERRUPT_I2C1_SCL                           (CYGNUM_HAL_INTERRUPT_XTI_BASE+10)
#define CYGNUM_HAL_INTERRUPT_PORT_0_6                           (CYGNUM_HAL_INTERRUPT_XTI_BASE+11)
#define CYGNUM_HAL_INTERRUPT_SPI1_SCLK                          (CYGNUM_HAL_INTERRUPT_XTI_B.......
#define CYGNUM_HAL_INTERRUPT_UART1_RX                           (CYGNUM_HAL_INTERRUPT_XTI_BASE+13)
#define CYGNUM_HAL_INTERRUPT_PORT_0_13                          (CYGNUM_HAL_INTERRUPT_XTI_BASE+14)
#define CYGNUM_HAL_INTERRUPT_UART2_RX                           (CYGNUM_HAL_INTERRUPT_XTI_BASE+14)
#define CYGNUM_HAL_INTERRUPT_PORT_0_15                          (CYGNUM_HAL_INTERRUPT_XTI_BASE+15)
#define CYGNUM_HAL_INTERRUPT_WAKEUP                             (CYGNUM_HAL_INTERRUPT_XTI_BASE+15)
Inital:
//set values for interrupt configuration structure
strXti_IntrptIgniton.int_num = CYGNUM_HAL_INTERRUPT_WAKEUP;
strXti_IntrptIgniton.XTI_ISR = GenaralXTIISR;
strXti_IntrptIgniton.XTI_DSR = NULL;  //no need for DSR ,so set it to NULL
strXti_IntrptIgniton.bRisingEdge = 1;  //rise edge to trigger the interrupt. zero means falling edge.

//configure wake up line(igniton ) interrupt, rising edge triggers the interrupt
if(XTIWakeupInterruptsConfig(&strXti_IntrptIgniton)==BB_FAILURE)
{
.....}
HAL_INTERRUPT_MASK(CYGNUM_HAL_INTERRUPT_WAKEUP);

    //configure Ex-Alert switch interrupt, falling edge triggers the interrupt
    strXti_IntrptExAlert = strXti_IntrptIgniton;
    strXti_IntrptExAlert.bRisingEdge = 0;//rise edge to trigger the interrupt. zero means falling edge.
    strXti_IntrptExAlert.int_num = CYGNUM_HAL_INTERRUPT_PORT_2_8;
   
if(XTIWakeupInterruptsConfig(&strXti_IntrptExAlert)==BB_FAILURE)
{
.....}
HAL_INTERRUPT_MASK(CYGNUM_HAL_INTERRUPT_PORT_2_8);

    //configure Tamper switch interrupt, falling edge triggers the interrupt
    strXti_IntrptTamper = strXti_IntrptExAlert;
    strXti_IntrptTamper.bRisingEdge = 1;//rise edge to trigger the interrupt. zero means falling edge.
    strXti_IntrptTamper.int_num = CYGNUM_HAL_INTERRUPT_PORT_2_9;
if(XTIWakeupInterruptsConfig(&strXti_IntrptTamper)==BB_FAILURE)
{
....}
HAL_INTERRUPT_MASK(CYGNUM_HAL_INTERRUPT_PORT_2_9);

    //configure motion sensor line interrupt, rising edge triggers the interrupt;
strXti_IntrptIMotionSensor = strXti_IntrptTamper;
strXti_IntrptIMotionSensor.bRisingEdge = 1;//rise edge to trigger the interrupt. zero means falling edge.
strXti_IntrptIMotionSensor.int_num = CYGNUM_HAL_INTERRUPT_PORT_1_13;
if( XTIWakeupInterruptsConfig(&strXti_IntrptIMotionSensor) == BB_FAILURE)
{
....     }
HAL_INTERRUPT_MASK(CYGNUM_HAL_INTERRUPT_PORT_1_13);

   ....
SINT16 XTIWakeupInterruptsConfig( APP_BA_XTI_INTERRUPT *pstrXti_Intrpt)
{
....//XTI_ISR is not allowed to be NULL, but XTI_DSR could be. But that must be confirmed by the implemetation of XTI_ISR.
.....//refer to Str7xx_serial.c in Ecos source codes
...
//Create a interrupt object and returns a handle to it.
....//configure whether rising edge or falling edge trigger the interrupt.
....
//Attach the interrupt to the vector so that interrupts will be delivered to the ISR when the interrupt occurs
...
//Program the interrupt controller to re-allow delivery of interrupts on the given vector
.....}

Before sleep:
    // Switch off PLL
....    //Enable RTC Wake up line
....
    // First mask all XTI interrups.
.....    //Enable Wake up line
    HAL_INTERRUPT_CONFIGURE(CYGNUM_HAL_INTERRUPT_WAKEUP,  0, 1); // Rising edge
    HAL_INTERRUPT_UNMASK(CYGNUM_HAL_INTERRUPT_WAKEUP);
...

        //Enable Tamper line
        HAL_INTERRUPT_CONFIGURE(CYGNUM_HAL_INTERRUPT_PORT_2_9,  0, 1); // Rising edge
        HAL_INTERRUPT_UNMASK(CYGNUM_HAL_INTERRUPT_PORT_2_9);
......

    //Enable Ex-Alert line
    HAL_INTERRUPT_CONFIGURE(CYGNUM_HAL_INTERRUPT_PORT_2_8,  0, 0); // falling edge
    HAL_INTERRUPT_UNMASK(CYGNUM_HAL_INTERRUPT_PORT_2_8);

    //Enalbe motion sensor line
....        HAL_INTERRUPT_CONFIGURE(CYGNUM_HAL_INTERRUPT_PORT_1_13, 0, 1); // Rising edge   
...
    }
Stop Code:
/*
The MCU power consumption during STOP mode can be reduced by:
- Stopping the Main Voltage Regulator by setting bit LPVRWFI in the PCU_PWRCR register
- Putting the FLASH in power-down mode by setting bit PWD in the FLASH_CR0 register
(refer to the STR7 Flash programming reference manual)
*/

{
......
    // Clear STOP bit and set WAKEUP bit. Write the register twice to
    // reset the stop mode sequencer.
.....
    // Stopping the Main Voltage Regulator by setting bit LPVRWFI in the PCU_PWRCR register
....
    //Putting the FLASH in power-down mode by setting bit PWD in the FLASH_CR0 register
....
    // Clear STOPI bit in PRCCU CFR reg
....
    // Enter stop mode by writing 1,0,1 to the XTI CTRL reg stop bit.
....
    // Spin a while to absorb the time needed to go into stop mode and
    // come out of it again.

....
    // At this point we have either stopped and restarted or failed to
    // stop for some reason. Take a look at the STOP and STOPI bits to
    // see what happened.
....
    if( !((xti_ctrl & CYGARC_HAL_STR7XX_XTI_CTRL_STOP) == 0 &&
          (cfr & CYGARC_HAL_STR7XX_PRCCU_CFR_STOPI) != 0) )
    {
        // STOP and STOPI bits do not indicate that a stop
        // occurred. Return false.
...
    }

    // Clear WKUP bit to allow these lines to function as interrupts again.
....}

   After enable these wakeup-line:
        cyg_uint32 xtibase = CYGARC_HAL_STR7XX_XTI_BASE;
        cyg_uint32 tral = CYGARC_HAL_STR7XX_XTI_TRL;
        cyg_uint32 trah = CYGARC_HAL_STR7XX_XTI_TRH;
        HAL_READ_UINT8( xtibase+tral, gtrl );
        HAL_READ_UINT8( xtibase+trah, gtrh );

    Read from XTI trigger polarity register :
    gtrl:0x88,  gtrh:0x81
   XTI_TRH: 0x81 (10000001)
        CYGNUM_HAL_INTERRUPT_PORT_0_15  /CYGNUM_HAL_INTERRUPT_PORT_0_15  :1
           CYGNUM_HAL_INTERRUPT_PORT_1_14  /CYGNUM_HAL_INTERRUPT_HDRX /CYGNUM_HAL_INTERRUPT_I2C0_SDA :1

XTI_TRL: 0x88 (10001000)
CYGNUM_HAL_INTERRUPT_PORT_1_13 /CYGNUM_HAL_INTERRUPT_HCLK /CYGNUM_HAL_INTERRUPT_I2C0_SCL :1
CYGNUM_HAL_INTERRUPT_PORT_2_9   :1
CYGNUM_HAL_INTERRUPT_PORT_2_8   :0







沙发
Alex.Ron|  楼主 | 2011-5-28 13:36 | 只看该作者
有没有可能是硬件没有去抖电路?

使用特权

评论回复
板凳
Alex.Ron|  楼主 | 2011-5-28 13:43 | 只看该作者
https://my.st.com/public/STe2eco ... mp;currentviews=584
这是ST中的一个类似的问题。

使用特权

评论回复
地板
guqintai| | 2014-1-23 21:17 | 只看该作者
楼主,您好,可以给我发一点关于ecos移植于str710的资料吗?dongfx28@gmail.com

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

3

帖子

1

粉丝