Forum Discussion
Altera_Forum
Honored Contributor
8 years agoI am also getting the same issue, using IOWR_32DIRECT doesn't produce error and printfs after that call work, but as soon as I call IORD_32DIRECT, the printfs afterwards do not show. Does anyone know any possible reasons as to why my code is hanging up at IORD_32DIRECT?
(The usleep(20000)s are a way to "flush" the stdout buffers because I was having this issue: https://www.altera.com/support/support-resources/knowledge-base/solutions/rd07292005_415.html)#include <alt_types.h>#include <io.h># include <string.h># include "system.h"
# include "sys/alt_dma.h"
# include "sys/alt_flash.h"# include "sys/alt_flash_dev.h"# include "sys/alt_flash_dev.h"# include "sys/alt_stdio.h"//for alt_putbufflush()# include <stdio.h>
int main()
{
//===============Set Address===============
//int *THE_ADDRESS;
//THE_ADDRESS = (int)ADDRESS_SPAN_EXTENDER_0_WINDOWED_SLAVE_BASE;
int THE_ADDRESS;
THE_ADDRESS = (int)SINKSOURCE_0_BASE;
//===============Write===============
printf("Reading from Address: %08x \n", THE_ADDRESS);
usleep(200000);
printf("THE_ADDRESS: %08x \n", THE_ADDRESS);
usleep(200000);
int write_val = 0xffff;
IOWR_32DIRECT(THE_ADDRESS,0, write_val);
usleep(200000);
printf("Wrote %08x to %08x \n", write_val, THE_ADDRESS);
usleep(200000);
//===============Read===============
usleep(200000);
int val = IORD_32DIRECT(SINKSOURCE_0_BASE, 0); //PROGRAM STOPS HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
usleep(200000);
printf("Value at %08x: %08x \n", SINKSOURCE_0_BASE, val);
usleep(200000);
return 0;
}