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.

problem to send an analog continuous signal through GPIO pins

Hi everyone !

I need to order a xenon lamp, which functions by "flash" : so this lamp has 3 wires : 2 for the alimentation and the ground, and 1 for the order.

But before coming to this lamp, my "signal of order" goes through a converter which transform 12V in 200V.

So i need to send an analog continuous signal on this pin, if you understand me.

I tried use GPADAT and GPASET but it doesn't work.

I tried GPIOPADCONFIGSET for declaring the signal like analog signal, but it doesn't work too.

So sorry for my stupid question, but i need to approve this quicklier.

Thanks for your help !

Regards,

Sébastien.

  • Salut Sébastien!

    Why do you want to use exactly "analog signal" if you need only two level: high and low (if I understand right about your xenon lamp). In my opinion you need to initialize any GPIO-pin for output mode and to form the discrete signal for driving of lamp. Only you should remember that GPIO-pin gives 3.3 V only. The example of initialization you can look  at 

    //###########################################################################
    // FILE:   external_interrupt_c28.c
    // TITLE:  External Interrupt test Program.
    //
    //! \addtogroup control_example_list
    //! <h1> External Interrupts (external_interrupt)</h1>
    //!
    //! This program sets up PA0_GPIO0 as XINT1 and PA1_GPIO1 as XINT2.  Two other
    //! GPIO signals are used to trigger the interrupt (PE6_GPIO30 triggers
    //! XINT1 and PE7_GPIO31 triggers XINT2).
    //! Connect a jumper across rows A and B at position 2 and 19 of the ABC header
    //! to route PE6_GPIO30 and PE7_GPIO31 to the pins at the base.The user must
    // then
    //! externally connect these pins(PE6_GPIO30 to PA0_GPIO0 and PE7_GPIO31 to
    //! PA1_GPIO1) at the base board for the program to work properly.
    //!
    //! XINT1 input is synched to SYSCLKOUT
    //! XINT2 has a long qualification - 6 samples at 510*SYSCLKOUT each.
    //!
    //! PF2_GPIO34 will go high outside of the interrupts and low within the
    //! interrupts. This signal can also be monitored on a scope.
    //!
    //! Each interrupt is fired in sequence - XINT1 first and then XINT2
    //!
    //! \b Watch \b Variables \n
    //! - Xint1Count    - Number of times XINT1 interrupt fires
    //! - Xint2Count    - Number of times XINT2 interrupt fires
    //! - LoopCount     - Number of times through the idle loop
    //
    //###########################################################################
    // $TI Release: F28M35x Support Library v160 $
    // $Release Date: Tue Nov  6 08:48:09 CST 2012 $
    //###########################################################################
    
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    #include <string.h>
    
    // Prototype statements for functions found within this file.
    interrupt void xint1_isr(void);
    interrupt void xint2_isr(void);
    
    // Global variables for this example
    volatile Uint32 Xint1Count;
    volatile Uint32 Xint2Count;
    Uint32 LoopCount;
    
    #define DELAY (CPU_RATE/1000*6*510)  //Qual period at 6 samples
    
    void main(void)
    {
        Uint32 TempX1Count;
        Uint32 TempX2Count;
    
    // Step 1. Initialize System Control:
    // Enable Peripheral Clocks
    // This example function is found in the F28M35x_SysCtrl.c file.
        InitSysCtrl();
        
    // If project is linked into flash, copy critical code sections to RAM.    
    #ifdef _FLASH
       memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
    #endif        
    
    // Step 2. Initalize GPIO:
    // This example function is found in the F28M35x_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    // InitGpio();  // Skipped for this example
    
    // Step 3. Clear all interrupts and initialize PIE vector table:
    // Disable CPU interrupts
        DINT;
    
    // Initialize PIE control registers to their default state.
    // The default state is all PIE interrupts disabled and flags
    // are cleared.
    // This function is found in the F28M35x_PieCtrl.c file.
        InitPieCtrl();
    
    // Disable CPU interrupts and clear all CPU interrupt flags:
        IER = 0x0000;
        IFR = 0x0000;
    
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    // This will populate the entire table, even if the interrupt
    // is not used in this example.  This is useful for debug purposes.
    // The shell ISR routines are found in F28M35x_DefaultIsr.c.
    // This function is found in F28M35x_PieVect.c.
        InitPieVectTable();
    
    // Interrupts that are used in this example are re-mapped to
    // ISR functions found within this file.
        EALLOW; // This is needed to write to EALLOW protected registers
        PieVectTable.XINT1 = &xint1_isr;
        PieVectTable.XINT2 = &xint2_isr;
        EDIS;  // This is needed to disable write to EALLOW protected registers
    
    // Step 4. Initialize all the Device Peripherals:
    // This function is found in F28M35x_InitPeripherals.c
    // InitPeripherals(); // Not required for this example
    
    // Step 5. User specific code, enable interrupts:
    
    // Clear the counters
        Xint1Count = 0; // Count XINT1 interrupts
        Xint2Count = 0; // Count XINT2 interrupts
        LoopCount = 0; // Count times through idle loop
    
    // Enable XINT1 and XINT2 in the PIE: Group 1 interrupt 4 & 5
    // Enable INT1 which is connected to WAKEINT:
        PieCtrlRegs.PIECTRL.bit.ENPIE = 1;         // Enable the PIE block
        PieCtrlRegs.PIEIER1.bit.INTx4 = 1;         // Enable PIE Group 1 INT4
        PieCtrlRegs.PIEIER1.bit.INTx5 = 1;         // Enable PIE Group 1 INT5
        IER |= M_INT1;                             // Enable CPU INT1
        EINT;                                      // Enable Global Interrupts
    
    // PE6_GPIO30 & PE7_GPIO31 are outputs, start PE6_GPIO30 high and PE7_GPIO31 low
        EALLOW;
        GpioG1DataRegs.GPASET.bit.GPIO30 = 1;        // Load the output latch
        GpioG1CtrlRegs.GPAMUX2.bit.GPIO30 = 0;       // GPIO
        GpioG1CtrlRegs.GPADIR.bit.GPIO30 = 1;        // output
    
        GpioG1DataRegs.GPACLEAR.bit.GPIO31 = 1;      // Load the output latch
        GpioG1CtrlRegs.GPAMUX2.bit.GPIO31 = 0;       // GPIO
        GpioG1CtrlRegs.GPADIR.bit.GPIO31 = 1;        // output
        EDIS;
    
    // PA0_GPIO0 and PA1_GPIO1 are inputs
        EALLOW;
        GpioG1CtrlRegs.GPAMUX1.bit.GPIO0 = 0;        // GPIO
        GpioG1CtrlRegs.GPADIR.bit.GPIO0 = 0;         // input
        GpioG1CtrlRegs.GPAQSEL1.bit.GPIO0 = 0;       // XINT1 Synch to SYSCLKOUT
                                                     // only
    
        GpioG1CtrlRegs.GPAMUX1.bit.GPIO1 = 0;        // GPIO
        GpioG1CtrlRegs.GPADIR.bit.GPIO1 = 0;         // input
        GpioG1CtrlRegs.GPAQSEL1.bit.GPIO1 = 2;       // XINT2 Qual using 6 samples
        GpioG1CtrlRegs.GPACTRL.bit.QUALPRD0 = 0xFF;  // Each sampling window is
                                                     // 510*SYSCLKOUT
        EDIS;
    
    // PA0_GPIO0 is XINT1, PA1_GPIO1 is XINT2
        EALLOW;
        GpioG1TripRegs.GPTRIP4SEL.bit.GPTRIP4SEL = 0; //Map Trip Input 4(XINT1) to
                                                      // PA0_GPIO0
        GpioG1TripRegs.GPTRIP5SEL.bit.GPTRIP5SEL = 1; //Map Trip Input 5(XINT2) to
                                                      // PA1_GPIO1
        EDIS;
    
    // Configure XINT1 and XINT2
        XIntruptRegs.XINT1CR.bit.POLARITY = 0;     // Falling edge interrupt
        XIntruptRegs.XINT2CR.bit.POLARITY = 1;     // Rising edge interrupt
    
    // Enable XINT1 and XINT2
        XIntruptRegs.XINT1CR.bit.ENABLE = 1;       // Enable XINT1
        XIntruptRegs.XINT2CR.bit.ENABLE = 1;       // Enable XINT2
    
    // PF2_GPIO34 will go low inside each interrupt.  Monitor this on a scope
        EALLOW;
        GpioG1CtrlRegs.GPBMUX1.bit.GPIO34 = 0;       // GPIO
        GpioG1CtrlRegs.GPBDIR.bit.GPIO34 = 1;        // output
        EDIS;
    
    // Step 6. IDLE loop:
        for(;;)
        {
    
            TempX1Count = Xint1Count;
            TempX2Count = Xint2Count;
    
            // Trigger both XINT1
            GpioG1DataRegs.GPBSET.bit.GPIO34 = 1; // PF2_GPIO34 is high
            GpioG1DataRegs.GPACLEAR.bit.GPIO30 = 1; // Lower PE6_GPIO30, trigger
                                                    // XINT1
            while(Xint1Count == TempX1Count) {}
    
            // Trigger both XINT2
    
            GpioG1DataRegs.GPBSET.bit.GPIO34 = 1; // PF2_GPIO34 is high
            DELAY_US(DELAY);                    // Wait for Qual period
            GpioG1DataRegs.GPASET.bit.GPIO31 = 1; // Raise PE7_GPIO31, trigger XINT2
            while(Xint2Count == TempX2Count) {}
    
            // Check that the counts were incremented properly and get ready
            // to start over.
            if(Xint1Count == TempX1Count+1 && Xint2Count == TempX2Count+1)
            {
                LoopCount++;
                GpioG1DataRegs.GPASET.bit.GPIO30 = 1; // raise PE6_GPIO30
                GpioG1DataRegs.GPACLEAR.bit.GPIO31 = 1; // lower PE7_GPIO31
            }
            else
            {
                asm ("      ESTOP0"); // stop here
            }
    
        }
    
    }
    
    // Step 7. Insert all local Interrupt Service Routines (ISRs) and functions
    // here:
    // If local ISRs are used, reassign vector addresses in vector table as
    // shown in Step 5
    
    interrupt void xint1_isr(void)
    {
        GpioG1DataRegs.GPBCLEAR.all = 0x4;   // PF2_GPIO34 is low
        Xint1Count++;
    
        // Acknowledge this interrupt to get more from group 1
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }
    
    interrupt void xint2_isr(void)
    {
        GpioG1DataRegs.GPBCLEAR.all = 0x4;   // PF2_GPIO34 is low
        Xint2Count++;
    
        // Acknowledge this interrupt to get more from group 1
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }
    
    
    
    
    .

    Regards,

    Igor

  • Salut Igor!

    I talked about analog signal because like i go through a 12V -> 200V converter which works with analog signal, it's necessary to put an analog signal on this 'order wire', and a bit, like a value 1, don't change anything for this kind of module.

    Moreover i tried use a GPASET on C28 with this kind of initialization like you sent me but the lamp doesn't flash, and the lamp works very well because with a battery of 4V it works.

    ...And if i  debug this, i will have many results about the others modules.

    Regards,

    Sébastien.

  • Salut Sébastien!

    "the lamp works very well because with a battery of 4V it works."

    Certainly you need to use some decoupling chain (for example optocoupler) for increasing voltage and for providing of consumed current. GPIO provides 4 mA max.

    Regards,

    Igor