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.

SAR interrupt in EVM5515

Hello!

I am working with EVM5515 and CCSv4.

I've done a simple project to prove the SAR interrupts. I declared a loop in the main in order to wait for SAR interrupts. Once a SAR interrupt is done, I increment the value of a variable. However, I wanted that the interrupt occurred when I press a button (SW6-SW15). However, There are lots of interrupts even if I do not press any button.

I Don't know why. I configurated SAR in this way:

void

Init_SAR(void)

{

*SARCTRL = 0x3C00;

// select AIN3, which is GPAIN1

//*SARDATA;

*SARCLKCTRL = 0x0031;

// 100/50 = 2MHz

*SARPINCTRL = 0x7104;

*SARGPOCTRL = 0x0040;

}

 

I am a little lost. Please help.

Thankyou!

  • Hello Albert,

       Your clock control looks fine , but you may want to check the other configuration.

       In the SAR control register I see that ADC start bit is reset and  also you may have to set appropriate channel using Channel configuration.

       I am not sure why you need to set  GPAIN 1 in SARGPOCTRL register

       Also in SARPINCTRL register you need to set the REFBUFFEN, if you use bandgap generated reference.

       Refernce Example:  You can find similar example in the CSL SAR example folder - the example name is "CSL_SAR_IntcExample"

       Hope this information helps.

    Regards

     Vasanth

     

      

  • SAR interrupts are to indiacte completion of SAR conversion process but not related to button presses. If you configure SAR for continuous, even you do not presss the buttons, SAR generates interrupt on completion of every conversion cycles. If you press the button SAR register will have the digital value of voltage generated that button and If you do not press the button SAR register will have the digital value of default voltage on the channel configured.

    Refer to CSL SAR examples so that you will get some idea on how SAR operation differs for poll and interrupt modes.

    - Pratap.

  • Hello!

    Thank you for your answer. I will check it. However, I need to set GPAIN1 in SARGPOCTRL register because it is the channel connected to the keypad in EVM5515.

  • I've put the Start ADC Control Bit to 1. However I am not able to generate the interrupt when I want. I want only to enter the interrupt routine when a button is pressed. I think that there would be any way to do that. Depending on the button pressed, the program should do different things. I also look the CSL example but I can't see anything relevant.

    Thank you in advance

  • you may want to look at the CSL example  - C55_CSL_3_03_01_00\c55xx_csl\ccs_v5.0_examples\intc\CSL_INTC_Example   Which is quite close to your application.

    Regards

     Vasanth

     

  • Hello!

    Thanks for your replies! I have looked the example you told me, and I configured it as in the example:

    void

    Init_SAR(void)

    {

    SARCTRL = 0x3800;

    SARCLKCTRL = 0x0031;

    SARPINCTRL = 0x7100;

    SARGPOCTRL = 0;

    }

    void

    Start_SARconversion(void)

    {

    SARCTRL = SARCTRL | 0x8000;

    }

    interrupt

    void SAR_Isr(void)

    {

    // clear SAR int flag

    IFR0 = IFR0&0x2000;

    a=2;

    }

     

    However, once I call Init_SAR() function interrupts begin to happen even without calling Start_SARconversion().

    This is the main function:

    void

    main (void)

    {

    Init();

    //StartTimer0();

    Start_SARconversion();

    while(a==1);

    printf(

    "Program finished \n");

    }

     

    where a is a global variable initiliazed to 1.

    I do not know what I'm doing wrong!

  • Hello!

    By now, the program is working more or less. I say that because the interrupt occured when I press a button from the keyboard. However, I developed the program to send a command via I2C to a peripheral connected to the board and when I press the button from the keyboard the interrupt occured but the message is sent three or four times resulting in a collapse. I tried to fix it by desabling interrupts (IER0=0x0000) when entered and enabling at the end of the interrupt routine(IER0=0x2000), I also tried to changle the SAR clock bia SARCTRLCLK register but it didn't worked too.

    I think that the problem is that the interrupts occurs very fast and the same data is read many times.

    Hope you can help me!

    thank you!

  •  

    I beleive you are reading the value in the ISR ?  You can try add some delay once you read values and before re-enabling the Interrupt. This would confirm if multiple interrupt occuring.

    Regards

     Vasanth

  • Yes, I am reading  the value in ISR. In fact i've tried to introduce a delay, to reject a value if the data before is the same as the actual.

    By now, the I2C is not collapsed, however, I pressed a button and after I pressed the same button but different things occur. For example I programmed switch 12 to increment volume of the peripheral, and switch 14 to change the program (as peripheral has many programs in memory), However, when I press switch 12 the volume is incremented and If i press it another time, the program is changed.

    I do not know what kind of error could be that. But I can't get a regular behaviour from the keyboard,

    Thank you!