Ok, same topic but a different subject :)
Can anyone verify for me that the below code is what you'd expect to use to DMA a frame of video to the FIFO connected at the input of the VGA controller... I'm trying to narrow down whether I have a software problem or a hardware problem...
The symptoms are that my chip-select line on the VGA controller never seems to go high (it's a 'chipselect' type, not a 'chipselect_n' type). I connected it (via a counter) to the LEDG array-of-leds on the board, and there wasn't any activity. Since I'm not apparently getting a chip-select, I'm assuming that nothing is being sent to the VGA controller, hence the question about the code :)
static alt_dma_txchan _txchan;
static unsigned char * _vram = (unsigned char *)0xE00000;
static void nextFrameRequired(void* handle)
{
static int count = 0;
int rc;
if (count %60 == 0)
printf("x");
count ++;
// Re-schedule a DMA transfer, and call this callback again
if ((rc = alt_dma_txchan_send(_txchan, _vram, 640*480, nextFrameRequired, NULL)) < 0)
{
printf ("Failed to repost transmit request, reason = %i\n", rc);
}
}
int main(void)
{
int rc; // Result code
int failed = 0;
printf("\n\nStarting up the VGA controller\n");
// Start a transfer to the VGA controller
if ((_txchan = alt_dma_txchan_open(DMA_NAME)) == NULL)
{
printf ("Failed to open DMA channel to VGA controller\n");
failed = 1;
}
// We want to write to the VGA controller FIFO at VGA_BASE so
// set the DMA transactions to be WRITE_ONLY
if ((rc = alt_dma_txchan_ioctl(_txchan, ALT_DMA_TX_ONLY_ON, (void *)VGA_BASE)) < 0)
{
printf ("Failed to configure DMA, reason = %i\n", rc);
failed = 1;
}
// We want bytes to be written to the fifo
if ((rc = alt_dma_txchan_ioctl(_txchan,ALT_DMA_SET_MODE_8,0)) < 0)
{
printf("Failed to configure byte-writes\n");
failed = 1;
}
// Schedule a DMA transfer, and enable a callback that will
// reschedule a transfer when the current one is done. We transfer
// from the top of memory
if ((rc = alt_dma_txchan_send(_txchan, _vram, 640*480, nextFrameRequired, NULL)) < 0)
{
printf ("Failed to post transmit request, reason = %i\n", rc);
failed= 1;
}
printf("DMA scheduler activated. Failed = %d, Looping\n", failed);
// Loop forever
while (1)
{
int i;
int pixel = 0;
unsigned char *vram = _vram;
for (i=0; i<640*480; i++)
{
*vram ++ = pixel ++;
if (pixel == 21)
pixel = 0;
}
}
}
The RAM location (0xE00000) passes the DMA test from the Altera-supplied memtest.c template, so I ought to be able to read from there. If anyone is interested enough to look, the complete files are at
Thanks in advance for any help :)
Simon