This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS570LS3137: about the Real-Time Interrupt module

Part Number: TMS570LS3137


Tool/software: Code Composer Studio

when the RTI1 compare0 period reset,timer runs wrong.

As the program,the time of low level should depend on the RTI1 compare0 period. I set the RTI1 compare0 period=15ms.the time of low level is nearly 30ms,and is impacted by the "delay time"function.

/** @file sys_main.c 
*   @brief Application main file
*   @date 08-Feb-2017
*   @version 04.06.01
*
*   This file contains an empty main function,
*   which can be used for the application.
*/

/* 
* Copyright (C) 2009-2016 Texas Instruments Incorporated - www.ti.com 
* 
* 
*  Redistribution and use in source and binary forms, with or without 
*  modification, are permitted provided that the following conditions 
*  are met:
*
*    Redistributions of source code must retain the above copyright 
*    notice, this list of conditions and the following disclaimer.
*
*    Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the 
*    documentation and/or other materials provided with the   
*    distribution.
*
*    Neither the name of Texas Instruments Incorporated nor the names of
*    its contributors may be used to endorse or promote products derived
*    from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/


/* USER CODE BEGIN (0) */
/* USER CODE END */

/* Include Files */

#include "sys_common.h"

/* USER CODE BEGIN (1) */
#include "gio.h"
#include "het.h"
#include "mibspi.h"
#include "rti.h"
#include "can.h"
#include "sys_core.h"
#include "esm.h"
#include "sys_vim.h"
#include "i2c.h"
#include "spi.h"
#include "reg_vim.h"

void LED_drive();
/* USER CODE END */

/** @fn void main(void)
*   @brief Application main function
*   @note This function is empty by default.
*
*   This function is called after startup.
*   The user can use this function to implement the application.
*/

/* USER CODE BEGIN (2) */
uint16 tg0_int[1]={0x00};              //Mibspi���ݳ�ʼ��
uint16 tg0_transmit_data[1] = {0x10};  //Mibspi5����,���LED

uint16 ADC_transmit_data[9]={0x0c00,0x1c00,0x2c00,0x3c00,0x4c00,0x5c00,0x6c00,0x7c00,0x8c00};
uint16 ADC_transmit_complete=0x0000;
uint16 ADC_receive_data[101][9]={0};
uint32 data_sample = 0;
uint32 ADC_EOC;

uint64 empty_sample = 0,full_sample = 409500u,half_sample = 204900u;
uint32 sample_i,sample_j;
uint16 timer_flag;
uint8 rising_flag;
uint8 falling_flag;
uint8 success;
uint8 Rti_Flag = 1;
uint8 can_txdat1[8]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
/* USER CODE END */

uint8	emacAddress[6U] = 	{0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU};
uint32 	emacPhyAddress	=	0U;

int main(void)
{
/* USER CODE BEGIN (3) */
    _enable_interrupt_();
    vimInit();
    gioInit();                                      /* Initialize GIO driver */
    mibspiInit();                                   /* Initialize mibspi driver */
    rtiInit();
    canInit();
    vimInit();
    hetInit();
    spiInit();


//            lc's  codes   begin

    rtiEnableNotification(rtiNOTIFICATION_COMPARE0);/* Enable RTI Compare 0 interrupt notification */
    _enable_IRQ();
//    gioSetBit(hetPORT1, 9,0);
//    rtiSetPeriod(rtiCOMPARE0, 50000);
//    rtiStartCounter(rtiCOUNTER_BLOCK0);
    uint32 i;

    while(1)
    {
        rtiSetPeriod(rtiCOMPARE0, 500000);
        Rti_Flag = 50;
        gioSetBit(hetPORT1, 9,1);
        rtiStartCounter(rtiCOUNTER_BLOCK0);
        for(i=0; i<320000 ;i++)              /*delay time*/
        {
            asm(" nop");

        }
//        rtiStopCounter(rtiNOTIFICATION_COMPARE0);
        rtiResetCounter(rtiNOTIFICATION_COMPARE0);
        rtiSetPeriod(rtiCOMPARE0, 150000);
        Rti_Flag = 15;
        rtiStartCounter(rtiCOUNTER_BLOCK0);
        while(Rti_Flag != 0)
        {
            gioSetBit(hetPORT1, 9,0);
        }

    }


//            lc's  codes end



/* USER CODE END */

    return 0;
}


/* USER CODE BEGIN (4) */
void mibspiGroupNotification(mibspiBASE_t *mibspi, uint32 group)
{

    if(mibspi == mibspiREG3)
    {
        asm(" nop");
    }
}

void rtiNotification(uint32 notification)
{
    if(notification==rtiNOTIFICATION_COMPARE0)
    {


        /* USER CODE BEGIN (10) */
        /* USER CODE END */
        if(Rti_Flag == 15)
        {
            Rti_Flag=0;
//            gioToggleBit(hetPORT1, 9);
        }


//        if ((hetPORT1->DIN & (uint32)((uint32)1U << 9)) != 0U)
//        {
//            hetPORT1->DCLR = (uint32)1U << 9;
//            rtiSetPeriod(rtiCOMPARE0, 150000);
//        }
//        else
//        {
//            hetPORT1->DSET = (uint32)1U << 9;
//            rtiSetPeriod(rtiCOMPARE0, 50000);
//        }





//        rtiStopCounter(rtiCOUNTER_BLOCK0);
//            while(success==0)
//            {
//                success=rtiResetCounter(rtiCOUNTER_BLOCK0);
//            }
//            success=0;
//
//        switch(c)
//        {
//        case 0:
//            c=1;
//            gioSetBit(hetPORT1, 9,0);
//            rtiSetPeriod(rtiCOMPARE0, 100000);
//            break;
//        case 1:
//            c=0;
//            gioSetBit(hetPORT1, 9,1);
//            rtiSetPeriod(rtiCOMPARE0, 50000);
//            break;
//        default:
//            break;
//        }
//        rtiStartCounter(rtiCOUNTER_BLOCK0);
    }
}
void canMessageNotification(canBASE_t *node, uint32 messageBox)
{
    if(node==canREG1)
    {
        if(messageBox==1)
        {
            asm(" nop");
        }
        else if(messageBox==2)
        {
            asm(" nop");
        }
        else
        {
            asm(" nop");
        }
    }
}

/* USER CODE END */