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.

MSP432E401Y: Trouble driving PA2 SPICLK pin

Part Number: MSP432E401Y

Tool/software:

Hi,

I'm working on a board that has an opto-isolated ADC 7038 with an SPI interface.  If I talk to the 7038 directly without the opto-isolators it works fine, but when I try to talk to it through the opto-isolators and inverters it's not working.

The first thing I'm trying to do is to clean up the SSICLK signal and in order to do that I want to generate a square wave on that pin, PA2, and use it to improve the hardware.  But, I'm not having much luck. 

Right now all I'm trying to do is to switch PA2 from low to high.  Here is what I'm doing:

1. Observe that RCGCGPIO is FF 7F - Gating clocks are enabled

2. Observe that PRGPIO is FF 7F - GPIO modules are ready

3. Set SSICR1 to 0 - Disable QSSI0

4. Set RCGSSI to 0 - Disable SSI module

5. Set Port A GPIODIR to 04 - Set PA2 as an output

6. Set Port A GPIODEN to 0xFF - Digital enable Port A 

Then I write an 04 to GPIODATA (and also to 0x400583FC) and nothing happens. PA2 should go high, but it doesn't.

Can anyone see what I'm doing wrong here?

Thank you.

  • Hi Brad,

    I'm working on a board that has an opto-isolated ADC 7038 with an SPI interface.  If I talk to the 7038 directly without the opto-isolators it works fine, but when I try to talk to it through the opto-isolators and inverters it's not working.

    Does PA2 work when you don't have the opto-isolators?

    Right now all I'm trying to do is to switch PA2 from low to high.  Here is what I'm doing:

    1. Observe that RCGCGPIO is FF 7F - Gating clocks are enabled

    2. Observe that PRGPIO is FF 7F - GPIO modules are ready

    3. Set SSICR1 to 0 - Disable QSSI0

    4. Set RCGSSI to 0 - Disable SSI module

    5. Set Port A GPIODIR to 04 - Set PA2 as an output

    6. Set Port A GPIODEN to 0xFF - Digital enable Port A 

    Then I write an 04 to GPIODATA (and also to 0x400583FC) and nothing happens. PA2 should go high, but it doesn't.

    If you use TivaWare API to do the same, does it produce any difference?

    Are you saying that without the opto-isolators, the above code sequence will work? 

  • Hello Charles,

    Thank you for your response.

    I guess my post wasn't clear. The opto-isolators are not involved in this problem at this point, I just mentioned them to explain my ultimate goal. The board I'm working on right now doesn't have opto-isolators. I'm just trying to get control of the PA2 pin to start doing some testing.

    I'm not familiar with TivaWare API and I'm reluctant to start working with a high level language solution. My project is almost entirely run on assembly language once it get past initialization and I'm thinking I might need to write some assembly code to reliably get the data from the ADC7038 because of the problems I'm running into trying to get the data through the opto-isolators when I'm trying to read it using the SPI Port.

    I realize that I'm probably a minority of one, but I think assembly code is so much easier to work with than the high level languages.

    There has to be some simple reason that PA2 is not going high after the above steps 1-6 have been taken, but everything I know tells me that it should go high. I'm obviously missing an important step here.

  • Hi Brad,

      You may the one of the few if not the only one that I'm aware of writing software entirely in assembly. It will be extremely difficult for us to support. I really suggest you try out TivaWare SDK. It is really simple to use. If you insist to use assembly then please at least try out TivaWare and follow the disassembly code that is generated by the compiler. You can then compare with your own code sequence. 

    Using API, setting PA2 high could be as simple as  the following code. 

        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA))
        {
        }
        
    
        GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2);
    
        GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_2, GPIO_PIN_2);
    }

    Below are the register settings after running the above code. You can compare with your output. 

  • Hello Charles,

    It's working! As you suggested, I was able to use the disassembler with the TivaWare code you posted to find out how to toggle PA2 and it's working now. Thank you so much.

    I realize I might be the only one still using assembly code, but I was done with my engineering education a few years before the microprocessor was invented and assembly code was the only option when they first came out. I was never motivated to start using higher level languages because to me they add an unnecessary level of complexity to the final design. I still use C code for initialization, but after that it's almost all done in assembly.

    Even though it takes a little translating on my part, your answers to my questions have been extremely valuable to me and I don't know how I would have solved some of these issues without your answers.

    One last issue. The PA2 pin is connected to a 300 ohm resister to drive the opto-isolator so I need at least 10ma for that. Following the code you sent there is a command "GPIOPadConfigSet(ui32Port, ui8Pins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD)" that configures PA2 for 2ma.

    Is there some way to modify the TivaWare code you sent to tell it to configure PA2 to drive 12ma? It looks like that is the highest drive current option.

    Thank you.

  • Hi Brad,

     Glad that it is working for you now. As you can see, once you get a hang of it, the TivaWare APIs are simple to deal with. 

    I realize I might be the only one still using assembly code, but I was done with my engineering education a few years before the microprocessor was invented and assembly code was the only option when they first came out. I was never motivated to start using higher level languages because to me they add an unnecessary level of complexity to the final design. I still use C code for initialization, but after that it's almost all done in assembly.

    No worries. I started with Motorola 68000 assembly. :-)

    One last issue. The PA2 pin is connected to a 300 ohm resister to drive the opto-isolator so I need at least 10ma for that. Following the code you sent there is a command "GPIOPadConfigSet(ui32Port, ui8Pins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD)" that configures PA2 for 2ma.

    As you can see the source code for GPIOPinTypeGPIOOutput is to call GPIOPadConfigSet. 

    void
    GPIOPinTypeGPIOOutput(uint32_t ui32Port, uint8_t ui8Pins)
    {
        //
        // Check the arguments.
        //
        ASSERT(_GPIOBaseValid(ui32Port));
    
        //
        // Set the pad(s) for standard push-pull operation.
        //
        GPIOPadConfigSet(ui32Port, ui8Pins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
    
        //
        // Make the pin(s) be outputs.
        //
        GPIODirModeSet(ui32Port, ui8Pins, GPIO_DIR_MODE_OUT);
    }

    By default, it will configure the pad with 2mA strength. You can overwrite it by calling GPIOPadConfigSet with 12mA. See below. 

       SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA))
        {
        }
        
    
        GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2);
    
        GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_2, GPIO_STRENGTH_12MA, GPIO_PIN_TYPE_STD);
    
        GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_2, GPIO_PIN_2);
    }

    Here are the register settings. 

    Note that there will be several registers to configure for 12mA drive strength. Please refer to the table in the d/s. API will take care of the configuration for you easily. If you want to use assembly you must follow the d/s carefully on how to do it. Again, reference the disassembly code if you want to write in assembly.