Hello Arthur,
After I remove code from the functions in Zmod/baremetal/intc.c,the functionality of initializing ZmodADC has been consistently unusable.I've been trying to solve the issue of initializing the functionality of ZmodADC these past few days.This problem has been bothering me for quite some time.This is quite a strange question, I can't figure it out by myself, I feel like I still need some advice from you.Here's my main.c code.
//--------------------------------------------------
// blog.csdn.net/FPGADesigner
// copyright by CUIT Qi Liu
// Zynq Lwip TCP Communication Test Program
//--------------------------------------------------
#include "timer_intr.h"
#include "sys_intr.h"
#include "user_tcp.h"
#include "lwip/netif.h"
#include "sleep.h"
//#define TRANSFER_LEN 0xB
#define TIMER_LOAD_VALUE XPAR_CPU_CORTEXA9_0_CPU_CLK_FREQ_HZ / 8 //0.25S
static XScuGic Intc; //GIC
static XScuTimer Timer;//timer
//extern volatile unsigned tcp_client_connected;
//extern int tcp_trans_cnt;
void start_application(void);
#include "./Zmod/zmod.h"
#include "./ZmodADC1410/zmodadc1410.h"
#define SEND_SIZE 1463
//extern struct netif server_netif;
static char val_formatted[15];
#define TRANSFER_LEN 0x5B7
// ZMOD ADC parameters
#define ZMOD_ADC_BASE_ADDR XPAR_AXI_ZMODADC1410_0_S00_AXI_BASEADDR
#define DMA_ADC_BASE_ADDR XPAR_AXI_DMA_ADC_BASEADDR
#define IIC_BASE_ADDR XPAR_PS7_I2C_1_BASEADDR
#define FLASH_ADDR_ADC 0x30
#define ZMOD_ADC_IRQ XPAR_FABRIC_AXI_ZMODADC1410_0_LIRQOUT_INTR
#define DMA_ADC_IRQ XPAR_FABRIC_AXI_DMA_ADC_S2MM_INTROUT_INTR
//static char sendBuffer_main[TCP_SEND_BUFSIZE];
//--------------------------------------------------
// 中斷與定時器初始化
//--------------------------------------------------
void System_Init()
{
Timer_init(&Timer,TIMER_LOAD_VALUE,TIMER_DEVICE_ID);
Init_Intr_System(&Intc); // initial DMA interrupt system
Setup_Intr_Exception(&Intc);
Timer_Setup_Intr_System(&Intc,&Timer,TIMER_IRPT_INTR);
Timer_start(&Timer);
TcpTmrFlag = 0;
}
//--------------------------------------------------
// 主程序
//--------------------------------------------------
int main(void)
{
xil_printf("Im here~~~\n");
uint8_t channel=0;
uint8_t gain=0;
size_t length=TRANSFER_LEN;
ZMODADC1410 adcZmod(ZMOD_ADC_BASE_ADDR, DMA_ADC_BASE_ADDR, IIC_BASE_ADDR, FLASH_ADDR_ADC, ZMOD_ADC_IRQ, DMA_ADC_IRQ);
uint32_t *acqBuffer;
adcZmod.setGain(channel, gain);
acqBuffer = adcZmod.allocChannelsBuffer(length);
adcZmod.acquireImmediatePolling(acqBuffer, length);
static char time_formatted[15];
uint32_t valBuf;
int16_t valCh;
float val;
int coo;
xil_printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
struct netif *netif, server_netif; //用於lwIP網絡接口的通用數據結構
struct ip4_addr ipaddr, netmask, gw; //unsigned int
//開發板的MAC地址
unsigned char mac_ethernet_address[] = {
0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };
System_Init();
netif = &server_netif; //0x50C004
xil_printf("netif = %s\tnetif = 0x%p\t&server_netif = 0x%p\n", netif, netif, &server_netif);
//將4byte結構的IP地址轉換爲unsigned int
IP4_ADDR(&ipaddr, 192, 168, 1, 10); //IP地址(開發板)
IP4_ADDR(&netmask, 255, 255, 255, 0); //網絡掩碼
IP4_ADDR(&gw, 192, 168, 1, 1); //網關
lwip_init(); //初始化lwIP
//將網絡接口添加到netif_list中
if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, XPAR_XEMACPS_0_BASEADDR))
{
xil_printf("Error adding N/W interface\r\n");
return -1;
}
xil_printf("netif_final = %s\n", netif); //NULL
netif_set_default(netif); //設置默認網絡接口
netif_set_up(netif); //啓動網絡接口
tcp_send_init(); //初始化TCP PCB
xil_printf("New acquisition ------------------------\r\n");
xil_printf("Ch1\tRaw\tTime\t\r\n");
//
while(1)
{
if(TcpTmrFlag)
{
tcp_tmr();
TcpTmrFlag = 0;
}
xemacif_input(netif); //將MAC隊列中的packets傳輸到lwIP棧中
if (tcp_client_connected)
{ //連接成功則發送數據
xil_printf("TCP Connected");
/*
for (int i = 0; i < 30; i++)//
{
valBuf = acqBuffer[i];
valCh = adcZmod.signedChannelData(channel, valBuf);
val = adcZmod.getVoltFromSignedRaw(valCh, gain);
adcZmod.formatValue(val_formatted, 1000.0*val, "mV\r\n");
//xil_printf("%d\t%s\t\r\n",i,val_formatted);
strcat(sendBuffer,val_formatted);
}
*/
//send_data();
//xil_printf("tran_cnt:%d\r\n", tcp_trans_cnt);
xil_printf("Ready to send");
//strcpy(sendBuffer,"");
//adcZmod.freeChannelsBuffer(acqBuffer, length);
}
if (tcp_client_connected==-1)
{
xil_printf("errorrrrr exit\r\n");
return 0;
}
//sleep(2);
}
return 0;
}
And if I removed the initiate part of ZmodADC
uint8_t channel=0;
uint8_t gain=0;
size_t length=TRANSFER_LEN;
ZMODADC1410 adcZmod(ZMOD_ADC_BASE_ADDR, DMA_ADC_BASE_ADDR, IIC_BASE_ADDR, FLASH_ADDR_ADC, ZMOD_ADC_IRQ, DMA_ADC_IRQ);
uint32_t *acqBuffer;
adcZmod.setGain(channel, gain);
acqBuffer = adcZmod.allocChannelsBuffer(length);
adcZmod.acquireImmediatePolling(acqBuffer, length);
static char time_formatted[15];
uint32_t valBuf;
int16_t valCh;
float val;
int coo;
the code of can run successfully.
In my opinion, the Eclypse Z7 may have a certain procedure to confirm the normal execution of interrupt processes. When there is any abnormality in the interrupt process, other actions will not be executed. Of course, this is my observation based on experiments, which may not be accurate.
If you need any other information, please let me know. Thank you very much.