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.

TMS320F280049C: SPI in master mode is not working

Part Number: TMS320F280049C
Other Parts Discussed in Thread: TIC12400

I am using spi_ex4_eeprom.c driver lib example. I have probed my clock and it is working.  I am sending data on MOSI but it is not showing on probe. I am using 8bit and 1MHZ SPI clock.I am attaching my code. Thanks in advance.

2620.main.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//#############################################################################
//
// FILE: spi_ex4_eeprom.c
//
// TITLE: SPI EEPROM
//
//! \addtogroup driver_example_list
//! <h1>SPI EEPROM</h1>
//!
//! This program will write 8 bytes to EEPROM and read them back. The device
//! communicates with the EEPROM via SPI and specific opcodes. This example is
//! written to work with the SPI Serial EEPROM AT25128/256.
//!
//! \b External \b Connections \n
//! - Connect external SPI EEPROM
//! - Connect GPIO8/SPISIMO on controlCARD (GPIO16 on LaunchPad) to external
//! EEPROM SI pin
//! - Connect GPIO9/SPICLK on controlCARD (GPIO56 on LaunchPad) to external
//! EEPROM SCK pin
//! - Connect GPIO10/SPISOMI on controlCARD (GPIO17 on LaunchPad) to external
//! EEPROM SO pin
//! - Connect GPIO11/CS to external EEPROM CS pin
//!
//! \b Watch \b Variables \n
//! - None
//!
//
//#############################################################################
// $TI Release: F28004x Support Library v1.11.00.00 $
// $Release Date: Sun Oct 4 15:49:15 IST 2020 $
// $Copyright:
// Copyright (C) 2020 Texas Instruments Incorporated - http://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.
// $
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
device.h
7701.device.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//#############################################################################
//
// FILE: device.c
//
// TITLE: Device setup for examples.
//
//#############################################################################
// $TI Release: F28004x Support Library v1.11.00.00 $
// $Release Date: Sun Oct 4 15:49:15 IST 2020 $
// $Copyright:
// Copyright (C) 2020 Texas Instruments Incorporated - http://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.
// $
//#############################################################################
//
// Included Files
//
#include "device.h"
#include "driverlib.h"
#ifdef __cplusplus
using std::memcpy;
#endif
#define PASS 0
#define FAIL 1
uint32_t Example_PassCount = 0;
uint32_t Example_Fail = 0;
//*****************************************************************************
//
// Function to initialize the device. Primarily initializes system control to a
// known state by disabling the watchdog, setting up the SYSCLKOUT frequency,
// and enabling the clocks to the peripherals.
// The function also configures the GPIO pins 22 and 23 in digital mode.
// To configure these pins as analog pins, use the function GPIO_setAnalogMode
//
//*****************************************************************************
void Device_init(void)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Vohra,

    Which Serial EEPROM are you using? The example was written to work with Serial EEPROM AT25128/256.

    Most likely, you might need to adapt this code to different EEPROM.

    Also, looking into your code below, you seem be transmitting 0x00. So, you should see only see low signal on SPIMOSI.

            SPI_writeDataBlockingNonFIFO(SPIA_BASE,  registers[0]);
            SPI_writeDataBlockingNonFIFO(SPIA_BASE,  registers[1]);
            SPI_writeDataBlockingNonFIFO(SPIA_BASE,  registers[2]);
            SPI_writeDataBlockingNonFIFO(SPIA_BASE,  registers[3]);

    Regawrds,

    Manoj

  • I have edited spi_eeprom code for tic12400. I am able to read device id but when I try to write any register and read it back then it is not read back properly.

  • Vohra,

    Based on Figure 33 in tic12400 datasheet,

    DEVICE_ID has offset address value of 1, so, you need to configure SPI to transmit (on MOSI pin) 32 bits as show below

    1st byte to transmit bits 31:24      0x02

    2nd byte to transmit bits 23:16     0xXX (don't care)

    3nd byte to transmit bits 15:8       0xXX (don't care)

    4th byte to transmit bits 7:0          0xXX (don't care)

    CRC has offset address value of 3, so, you need to configure SPI to transmit (on MOSI pin) 32 bits as show below

    1st byte to transmit bits 31:24      0x06

    2nd byte to transmit bits 23:16     0xXX (don't care)

    3nd byte to transmit bits 15:8       0xXX (don't care)

    4th byte to transmit bits 7:0          0xXX (don't care)

    Check SPIMOSI pin and see whether you are transmitting correct address. Unless you get this correct, read commands won't work correctly for you.

    Regards,

    Manoj

  • I am writing like this only. I am able to read device ID and CRC register correctly. I am not able to correctly read back IN_EN register when I write 0xFFFFFF to it or to any other register.

  • Vohra,

    I am writing like this only. I am able to read device ID and CRC register correctly. I am not able to correctly read back IN_EN register when I write 0xFFFFFF to it or to any other register.

    This question needs to be answered by someone in tic12400 team as I haven't worked on tic12400 before. I have redirected this post to them.

    I expect them to return back to within 2 - 3 business days.

    Regards,

    Manoj

  • Vohra,

    You haven't provided any details on SPI write command. Based on the datasheet, this is what you need to transmit for write to IN_EN register. Did you make sure to transmit write command as shown below? What does your SPIRXBUF contents? Does it report SPI_FAIL bit set? I would also urge you to share oscilloscope scopeshots of SPI pins.

    IN_EN has offset address value of 1B, so, you need to configure SPI to transmit (on MOSI pin) 32 bits as show below for write command.

    1st byte to transmit bits 31:24      0xB7 (Bit 31: Write command | Bit 24 is '1')

    2nd byte to transmit bits 23:16     0xFF

    3nd byte to transmit bits 15:8       0xFF

    4th byte to transmit bits 7:0          0xFE (parity 0)

    Regards,

    Manoj

  • I probe the signal, when I read device id data is showing on MISO pin but when I write to IN_EN register then MOSI don't show any signal... I think there is some problem on MOSI PIN or configuration.

  • Can you please provide the signals you see when you probe the pins for us to review?  It is very difficult to help identify the source of your problem without being able to check the waveforms for errors.

    When you say "I think there is some problem on the MOSI PIN configuration" do you mean that you never see any signals on that pin with you probe?  Have you checked that the correct pin is enabled and configured as an output?

    Regards,

    Jonathan

  • Vohra,

    I haven't heard back from you for while. Is your issue resolved? Can I close this thread?

    Regards,

    Manoj

  • My issue was resolved...I was reading data after 4bytes is being transferred but actually we need to read it back after one transfer only.