Forum Discussion
BSP generation for I2C
- 26 days ago
Hi @paulgeisler
The I2C driver is missing because
i2c_0.csris not connected to the Nios Vdata_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:
- Connect
intel_niosv_m_0.data_managertoi2c_0.csr. - 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_sourceandtransfer_command_sinkunconnected. - Connect
i2c_0.interrupt_sendertoplatform_irq_rxwhen you want interrupt-driven transfers. The driver is still added from thecsrconnection. The interrupt routines are optional. - Generate the HDL, then generate the BSP again.
altera_avalon_i2cshould appear in the BSP, with an initialization entry fori2c_0inalt_sys_init.c.
For the pins,
sda_inandsda_oeneed one bidirectional open-drain buffer, andscl_inandscl_oeneed another, instantiated in the top-level design. Assigning those four ports directly to FPGA pins leaves them as separate inputs and outputs.Best Wishes
- Connect
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:
- Connect
intel_niosv_m_0.data_managertoi2c_0.csr. - 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_sourceandtransfer_command_sinkunconnected. - Connect
i2c_0.interrupt_sendertoplatform_irq_rxwhen you want interrupt-driven transfers. The driver is still added from thecsrconnection. The interrupt routines are optional. - Generate the HDL, then generate the BSP again.
altera_avalon_i2cshould appear in the BSP, with an initialization entry fori2c_0inalt_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