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.

TMS320F28069M: Delay in port setting using .set and .clear commands

Part Number: TMS320F28069M

Hello,

This might be be a stupid question ... this is about something as basic as setting a port value :-( But I have been stumped for a few days now.

The port has been setup as a output port.

GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0; // making it GPIO
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; // GPIO 0 is O/P.
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // internal pull up enabled

The code is as follows. 

if (gpio0 == 1) GpioDataRegs.GPASET.bit.GPIO0 = 1; else GpioDataRegs.GPACLEAR.bit.GPIO0 = 1;

The problem I am seeing is that, the value on the pin as observed by a scope seems to be delayed by a large amount, a few mS's !

The port setting and resetting is done in a timer ISR. There are other ports which I am reading in the ISR.

Am I missing anything ? Let me know if you guys think of anything at all.

Thanks -Bhaktha

  • Hi Bhakta,

    In the logic you are setting the pin high when it's already high. Is that correct ?

    Also if you setting and resetting the pin in time ISR then it'll depend in how your timer is setup. Which timer you are using and what clock source? Can you provide the detail on what is the expected time delay and what you are observing on scope?

    Regards,

    Vivek Singh

  • Vivek,

    I might be setting a pin high or low irrespective of the previous state. So ... I might be setting a pin when it is already high or setting it low when it is already low. Is this a problem. Somehow I thought I can set or clear, independent of the previous state of the pin. Is my understanding incorrect ?

    I am using timer 1. Setup is as follows. 

    //
    // Initialize address pointers to respective timer registers
    //
    CpuTimer1.RegsAddr = &CpuTimer1Regs;

    //
    // Initialize timer period to maximum
    //
    CpuTimer1Regs.PRD.all = 0xFFFFFFFF;

    //
    // Initialize pre-scale counter to divide by 1 (SYSCLKOUT)
    //
    CpuTimer1Regs.TPR.all = 0;
    CpuTimer1Regs.TPRH.all = 0;

    //
    // Make sure timers are stopped
    //
    CpuTimer1Regs.TCR.bit.TSS = 1;

    //
    // Reload all counter register with period value
    //
    CpuTimer1Regs.TCR.bit.TRB = 1;

    //
    // Reset interrupt counters
    //
    CpuTimer1.InterruptCount = 0;

    // Configuration of timer !

    PeriodInClocks = (Uint32) TIMERTICK;

    //
    // Counter decrements PRD+1 times each period
    //
    Timer->RegsAddr->PRD.all = PeriodInClocks - 1;

    //
    // Set pre-scale counter to divide by 1 (SYSCLKOUT)
    //
    Timer->RegsAddr->TPR.all = 0;
    Timer->RegsAddr->TPRH.all = 0;

    //
    // Initialize timer control register
    //

    //
    // 1 = Stop timer, 0 = Start/Restart Timer
    //
    Timer->RegsAddr->TCR.bit.TSS = 1;

    Timer->RegsAddr->TCR.bit.TRB = 1; // 1 = reload timer
    Timer->RegsAddr->TCR.bit.SOFT = 0;
    Timer->RegsAddr->TCR.bit.FREE = 0; // Timer Free Run Disabled

    //
    // 0 = Disable/ 1 = Enable Timer Interrupt
    //
    Timer->RegsAddr->TCR.bit.TIE = 1;

    //
    // Reset interrupt counter
    //
    Timer->InterruptCount = 0;

    I am issuing asm("   CLRC INTM"); in the timer ISR to enable other interrupts that are serviced while we are in the timer ISR

    My understanding was that the port will turn high or low, pretty much instantaneously after issuing the set or clear instruction. Worst case with a few sysclks delay.

    Appreciate if you can tell me the fault in my thinking/logic.

    Thanks. -Bhaktha

  • Hi,

    Yes, you can set/clear the pin irrespective of it's previous state but if you setting when it's already high then you'll not see any change in pin state.

    Can you explain how are you measuring the time delay on scope? What is the reference point ?

    Regards,

    Vivek Singh

  • Based on a increasing analog value, I am supposed to set a port high after the analog value reaches a threshold. Even though the analog values are increasing and the ADC is converting the values, based on these I set the ports, but when I see the analog value and port on a dual channel scope, there is a huge delay in the port value and the analog threshold value. Not sure if I am explaining it correctly.

    Another question, elsewhere on this forum I read that clocks have to be enabled for the ports peripheral block. But I don't see a setting for that anywhere. Is there one I should enable ? If so which register is that ?

    Thanks. -Bhaktha

  • Which analog value you are referring here. Can you provide more detail.

    On forum you'll have posts for different device which may have different architecture. I would recommend to go through the example code for that device and device document to find this info.

    Regards,

    Vivek Singh

  • The analog value we are converting in the ADC that will drive our decisions to turn on or off the ports. We did a unit test with a generated triangular waveform and the results of the test are inline with our expectations. There is something else going on in our system, I think. we will close this thread now and start a new one later if need be. Thanks for your help.

    Thanks. -Bhaktha