Forum Discussion

paulgeisler's avatar
paulgeisler
Icon for New Contributor rankNew Contributor
1 month ago
Solved

BSP generation for I2C

How do I get the BSP generator to generate code for the I2C that I added into the platform of the max10? It generates code for the JTAG but not the I2C. I made sure that I connected the SDA and SCL lines to external pins. See three screenshots.

  • Hi @paulgeisler


    The I2C driver is missing because i2c_0.csr is not connected to the Nios V data_manager. The BSP adds a driver for each peripheral that the processor masters. Exporting SDA and SCL does not make that connection.

    In Platform Designer:

    1. Connect intel_niosv_m_0.data_manager to i2c_0.csr.
    2. Set Interface for transfer command FIFO and receive data FIFO accesses to Avalon-MM Agent. In that mode the streaming ports are unused, so leave rx_data_source and transfer_command_sink unconnected.
    3. Connect i2c_0.interrupt_sender to platform_irq_rx when you want interrupt-driven transfers. The driver is still added from the csr connection. The interrupt routines are optional.
    4. Generate the HDL, then generate the BSP again. altera_avalon_i2c should appear in the BSP, with an initialization entry for i2c_0 in alt_sys_init.c.

    For the pins, sda_in and sda_oe need one bidirectional open-drain buffer, and scl_in and scl_oe need another, instantiated in the top-level design. Assigning those four ports directly to FPGA pins leaves them as separate inputs and outputs.


    Best Wishes

4 Replies

  • umut_arrow's avatar
    umut_arrow
    Icon for Occasional Contributor rankOccasional Contributor

    Hi,

    Firstly, your csr isn't connected looking at the screenshot of Platform Designer. Also you need to set the I2C IP to Avalon-MM Slave, instead of Avalon-ST.

    Lastly, I think you need to make sure your SDA/SCL pins are wired correctly. 

    I'm assuming you're following the Nios V tutorial, since your project is named AN 985. Take a look at Avalon I2C host core documentation as well, specifically "I2C Serial Interface Connection" section. SDA_IN and SDA_OE both should be connect to a bi-directional open-drain buffer, same as SCL_IN and SCL_OE.

  • Hi @paulgeisler


    The I2C driver is missing because i2c_0.csr is not connected to the Nios V data_manager. The BSP adds a driver for each peripheral that the processor masters. Exporting SDA and SCL does not make that connection.

    In Platform Designer:

    1. Connect intel_niosv_m_0.data_manager to i2c_0.csr.
    2. Set Interface for transfer command FIFO and receive data FIFO accesses to Avalon-MM Agent. In that mode the streaming ports are unused, so leave rx_data_source and transfer_command_sink unconnected.
    3. Connect i2c_0.interrupt_sender to platform_irq_rx when you want interrupt-driven transfers. The driver is still added from the csr connection. The interrupt routines are optional.
    4. Generate the HDL, then generate the BSP again. altera_avalon_i2c should appear in the BSP, with an initialization entry for i2c_0 in alt_sys_init.c.

    For the pins, sda_in and sda_oe need one bidirectional open-drain buffer, and scl_in and scl_oe need another, instantiated in the top-level design. Assigning those four ports directly to FPGA pins leaves them as separate inputs and outputs.


    Best Wishes

  • ai_responder's avatar
    ai_responder
    Icon for Community Manager rankCommunity Manager

    Thank you for your inquiry. To ensure an accurate response, your request has been routed to an Altera application engineer for further review and assistance.


    Note: To continue using AI Responder, please start your next inquiry with ai_responder

    Disclaimer (Beta): The AI Responder is currently provided as a beta feature. AI-generated responses may contain errors or omissions. Please verify technical guidance with official Altera documentation before implementation.

    Thank you very much.