How to toggle the Epiphany LED on Parallella

A forum for documenting the Parallella and Epiphany . (Not Q&A!)

How to toggle the Epiphany LED on Parallella

Postby aolofsson » Thu Mar 06, 2014 11:51 am

Toggling an LED is a great sanity check during a board bringup adventure (and provides an irrational amount of joy :D ).
This is how you do it with the Parallella. A little convoluted due to the routing modes, but the plan is to encapsulate these hardware twiddling routines inside functional calls for ease of use going forward.

A code snippet running on an Epiphany core showing how to set/reset the Epiphany LED (CR1 label on the board) :

Code: Select all
int main(void)
{
  e_coreid_t coreid;
  unsigned *addr;
  unsigned int led_state;


  //Get Value of LED State (this was passed in from the host)
  //The address 0x6000 was "agreed upon" between the Epiphany and the ARM host code.
  //Normally you would use proper arguments and symbols but this is low level code so deal with it...:-)

  addr=(unsigned *) (0x6000);
  led_state = (*(addr));

  //Set "direct north routing mode to access north IO registers
  //This is documented in the e16g301 datasheet. In order to access the IO registers we have to
  //change the eMesh routing mode to s special mode
  e_reg_write(E_REG_CONFIG, (unsigned) 0x00001000);

  //Write to north IO registers needed to enable the LED and set it's state 
  addr=(unsigned *) (0x80AF030c);
  (*(addr)) = 0x03FFFFFF;
  addr=(unsigned *) (0x80AF0318);
  (*(addr)) = ~led_state & 0x00000001;

  //Set config register back to normal to allow this core to starting routing eMesh writes normally.
  e_reg_write(E_REG_CONFIG, (unsigned) 0x00400000);

}


The complete example can be found at:
https://github.com/adapteva/epiphany-ex ... toggle-led

Cheers,
Andreas
User avatar
aolofsson
 
Posts: 1005
Joined: Tue Dec 11, 2012 6:59 pm
Location: Lexington, Massachusetts,USA

Re: How to toggle the Epiphany LED on Parallella

Postby theover » Fri Jun 27, 2014 3:55 pm

Hey,

I ran almost all the examples in the latest distribution on my 7010 board, and most work, including all the difficult ones like the reay tracing and Mandelbrot work fine, the system is stable except for sometimes serious file system errors when starting up, possibly because of power off too soon after "shutdown".

So I thought I'd see if I can add a little thing to "shutdown" that puts the user led off when shutdown is complete, or at least the umount has been done (because I often work over ethernet, and the X windows output is soon "off" because of a screen-saver I cannot easily shit off, and also killing the X server doesn't automatically get replaced by a text screen with the shutdown messages rolling down), but the problem is: the LED example doesn't work ! How could that be ?

T.
theover
 
Posts: 181
Joined: Mon Dec 17, 2012 4:50 pm

Re: How to toggle the Epiphany LED on Parallella

Postby theover » Fri Jun 27, 2014 4:38 pm

Correction: I've just tried again, using the actual commands from "sh -xv e-toggle-led" and now I saw the red LED going on, also by using the normal script: I had been looking at the Green User LED from the FPGA, sorry about that !

Is there a AXI interface readily available to toggle the Green LED as well ? Or should I look into the schematic and the verilog code to figure that out ?

T.V.
theover
 
Posts: 181
Joined: Mon Dec 17, 2012 4:50 pm

Re: How to toggle the Epiphany LED on Parallella

Postby FHuettig » Fri Jun 27, 2014 5:11 pm

theover wrote:Is there a AXI interface readily available to toggle the Green LED as well ? Or should I look into the schematic and the verilog code to figure that out ?
T.V.


The green LED CR10 is connected to an MIO pin on the Zynq. I addeed an example including a GPIO library to the parallella-utils repository.

The problem is that the 7020-based kickstarter boards were shipped with a flash image that does not connect that pin as a GPIO, and that part of the configuration can not be changed in the bitstream that gets loaded when Linux boots up (or that you can load later through the filesystem), it has to be done by the FSBL. If you have a 7010 board the LED will come on when the board powers-up so you'll know it's accessible, but for 7020 boards built before now the only way to get that LED to work is to re-program the flash memory.
-- Fred -- Hardware Guy --
FHuettig
 
Posts: 142
Joined: Wed Jan 29, 2014 8:30 pm
Location: Lexington, MA, USA


Return to Quick Start Guides , Documentation, Examples (Start Here!)

Who is online

Users browsing this forum: No registered users and 1 guest

cron