Community
cancel
Showing results for 
Search instead for 
Did you mean: 
psouz7
Beginner
168 Views

My LED is not blinking - My first NIOS II software tutorial - EP4CE6E22C8N

I am following the My first NIOS II software tutorial, everything works but my LED does not blink.

 

I am using Cyclone IV EP4CE6E22C8N I have feedback in the NIOS II console

 

My qsys file:

I haven't found a lot of things about system.h and files besides this old tutorial:

https://johnloomis.org/NiosII/pio/PIO_example1.html

 

I checked and part of the code was missing on altera_avalon_jtag_uart_regs.h file. So I added:

 

#define IOADDR_ALTERA_AVALON_PIO_DATA(base)      __IO_CALC_ADDRESS_NATIVE(base, 0)

#define IORD_ALTERA_AVALON_PIO_DATA(base)       IORD(base, 0)

#define IOWR_ALTERA_AVALON_PIO_DATA(base, data)    IOWR(base, 0, data)

 

#define IOADDR_ALTERA_AVALON_PIO_DIRECTION(base)   __IO_CALC_ADDRESS_NATIVE(base, 1)

#define IORD_ALTERA_AVALON_PIO_DIRECTION(base)    IORD(base, 1)

#define IOWR_ALTERA_AVALON_PIO_DIRECTION(base, data) IOWR(base, 1, data)

 

#define IOADDR_ALTERA_AVALON_PIO_IRQ_MASK(base)    __IO_CALC_ADDRESS_NATIVE(base, 2)

#define IORD_ALTERA_AVALON_PIO_IRQ_MASK(base)     IORD(base, 2)

#define IOWR_ALTERA_AVALON_PIO_IRQ_MASK(base, data)  IOWR(base, 2, data)

 

#define IOADDR_ALTERA_AVALON_PIO_EDGE_CAP(base)    __IO_CALC_ADDRESS_NATIVE(base, 3)

#define IORD_ALTERA_AVALON_PIO_EDGE_CAP(base)     IORD(base, 3)

#define IOWR_ALTERA_AVALON_PIO_EDGE_CAP(base, data)  IOWR(base, 3, data)

 

However the LED still not blinking, the function works because I put a printf function inside the while to read Srout variable.

 

#include <stdio.h>

#include "system.h"

#include "altera_avalon_pio_regs.h"

int main()

{

 

int Srout = 0x1;

int delay;

 

printf("Ola... vamos piscar LEDs..!\n");

 

while(1)

{

IOWR_ALTERA_AVALON_PIO_DATA(PIO_LED_BASE, Srout );

delay = 2000000;

//printf("Teste LED");

while (delay>0)

{

delay--;

}

printf("%d \n",Srout);

Srout = Srout << 1;

if (Srout >= 0x100)

Srout = 0x1;

}

 

return 0;

}

Where is my mistake? Maybe my board is not compatible with this tutorial, or with this library?

Tags (2)
0 Kudos
3 Replies
Eliath_G_Intel
Employee
124 Views

Hi Patricia Souza,

First of all, thank you so much for reaching us,

I'm Eliath and I'll help you with your issue.

Please give me a couple of days to review it carefully and give you an answer as soon as possible.

 

Thanks,

-Eliath Guzman

Eliath_G_Intel
Employee
124 Views

Hi Patricia,

 

please take a look at the following document:

My First Nios II Software Tutorial-DebuggingTheApplication

page 13 of the PDF, you can see the example code, similar to what you've done but the first argument of the function IOWR_ALTERA_AVALON_PIO_DATA () is no the same as the example design, which should be LED_PIO_BASE instead of PIO_LED_BASE.

These are macros and should match with the ones existing on the libraries used.

In section Debugging the Application , you will find a way to see if there is a mistake on connections or something else.

 

Please let me know if this worked for you.

Regards,

-Eliath

 

Eliath_G_Intel
Employee
124 Views

Hi Patricia,

Hoping you're doing well, I was wondering if the information shared with you was useful to solve your problem and if the issue is solved.

if you still have the same issue please let me know so I can help you with it.

if your issue has been solved, please let me know too so I can send the case to 'Close status', and after doing this, you'll have a period of 15 days to make a new post related to your issue.

 

Thanks,

-Eliath

Reply