我正在使用Arrow的Microsemi Smartfusion2开发套件。它使用Smartfusion2 M2S010-FG484 FPGA。 (https://www.arrow.com/en/products/sf2plus-dev-kit/arrow-development-tools)
我是Smartfusion2的新手,我正在尝试使用微控制器子系统(MSS)在Smartfusion2 FPGA和Arduino之间建立连接,并在软件话务台中对ti进行编程。问题是我似乎无法让它发挥作用。在尝试调试时,我将一个LED(我不得不即兴,因为我没有示波器)连接到开发板上的arduino连接器(J2)的第3个引脚。该引脚应包含从器件选择3(FPGA上的引脚J18),如第16页的数据表(https://static4.arrow.com/-/media/images/part-detail-pages/sf2-plus/new-sf2-files/sf2plus_user_guide_v1p1.pdf?la=zh-cn)和Libero SoC的I / O编辑器所示。
使用以下代码我试图切换LED /选择并取消选择指定的从站(从站3)。但没有任何反应。从机选择为低电平有效,但LED始终亮,从不关闭。
/*
* main.c
*
* Created on: Aug 16, 2017
*/
#include "drivers/mss_gpio/mss_gpio.h"
#include "drivers/mss_spi/mss_spi.h"
#include <stdio.h>
/*Delay function in milliseconds, for 100MHz clock*/
void Delay(uint32_t Delayms){
uint32_t i = 0;
uint32_t DelayValue = Delayms*2000; //1000ms*100000 = 100000000 (100MHz)
for(i = 0; i <= DelayValue; i++){
}
}
/*Configuration for SPI0*/
void ConfigSPI1(void){
/*Initialize and Configure SPI1*/
MSS_SPI_init(&g_mss_spi1);
MSS_SPI_disable(&g_mss_spi1); //Disable SPI1
/*Configure SPI1 as master, protocol mode, clk speed, frame size*/
MSS_SPI_configure_master_mode(
&g_mss_spi1, //Selects SPI1 for configuration
MSS_SPI_SLAVE_3, //Set the target device as slave 3
MSS_SPI_MODE2, //Serial peripheral interface operating mode
64u, //Divider used on APB bus (PCLK) clock in order to generate the SPI clock
12); //Number of bits making up the frame, max = 32
MSS_SPI_enable(&g_mss_spi1); //Enable SPI1
}
/*SPI0 test function*/
void SPI1Test(void){
MSS_SPI_set_slave_select(&g_mss_spi1, MSS_SPI_SLAVE_3); //Used by a MSS SPI master to select a specific slave
MSS_SPI_transfer_frame(&g_mss_spi1, 0xaaa); //Transfers "0xaaa" to the selected slave (slave 3)
Delay(1000); // I used this delay for testing, to keep the SS low for a longer time to be able to see the LED turn off
MSS_SPI_clear_slave_select(&g_mss_spi1, MSS_SPI_SLAVE_3); //Used by a MSS SPI master to deselect a specific slave
}
int main(){
/*Configure modules*/
ConfigSPI1();
/*Infinite loop*/
for(;;){
SPI1Test();
Delay(3000);
}
return 0;
}
有没有人在我的代码中看到可能导致问题的错误?或者可能有一个工作示例代码给我?
我写了另一个程序来切换引脚J18 /从选择3引脚和gpio驱动程序,这很有效,它切换了LED。我也很确定Libero SoC中的设计是正确的并正确导入。
感谢您的时间!