Xcore 200 Multichannel Audio Platform - LEDS problem Topic is solved

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
paolovecchiotti
Junior Member
Posts: 6
Joined: Tue Mar 15, 2016 5:00 pm

Xcore 200 Multichannel Audio Platform - LEDS problem

Postby paolovecchiotti » Tue Mar 15, 2016 5:33 pm

Hello everyone,

I am new with Xcore 200 Multichannel Audio Platform. I am trying to develop simple code to understand how the board works.

One of the first program that I wrote, following the tutorial example, aims to turn on LEDs on the board.

The code is:

# include <stdio.h>
# include <platform.h>
# include <xs1.h>
# include <timer.h>

out port col = XS1_PORT_4D;
out port row = XS1_PORT_4C;

int main (void) {
while (1) {

col <: 0XF;
row <: 0X0;
delay_milliseconds (200);

col <: 0X0;
row <: 0XF;
delay_milliseconds (200);

}
return 0;
}


As result, LEDs do not flash.

Successively, with the help of the datasheets, I measured with the oscilloscope the Voltage at the gates of the Mosfets which control LEDs. The signal I observed was High (3V) for P-mosfets, and low (0V) for N-mosfet, and not a square signal with period 2*200 ms as it was supposed to be. That means the relative output ports were not working.

I also tried to control a 1-bit port, the digital audio output (XS1_PORT_1D), with a similar code. Measuring the voltage with the oscilloscope at the piloting signal in the relative integrated component, I was able to observe the square signal at period 2*200ms.

Where does my error lie?

Thank you

Paolo
View Solution
User avatar
mon2
XCore Legend
Posts: 1514
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Tue Mar 15, 2016 9:36 pm

Hello Paolo. Welcome to the XMOS User Forum. Thought your question sounded familiar :)

Please review this thread:

http://mail.xcore.com/forum/viewtopic.php?f=47&t=4235

Summary: The XCORE-200 CPU present on this development board features 2 Tiles. Respectively, when you work with the GPIO pins, you must specifically define which tile should be used for the proper pin access. By default, you will be working with Tile # 0. For the LED matrix, the LEDs are bonded to Tile # 1.

Hope this helps.
User avatar
infiniteimprobability
XCore Legend
Posts: 1121
Joined: Thu May 27, 2010 10:08 am

Postby infiniteimprobability » Thu Mar 17, 2016 1:18 pm

Maybe this might help...

Code: Select all

out port p_leds_col                      = on tile[1]: XS1_PORT_4C;     //4x4 LED matrix
out port p_leds_row                      = on tile[1]: XS1_PORT_4D;


//Sets or clears pixel. Origin is bottom left scanning right
typedef interface led_matrix_if {
    void set(unsigned col, unsigned row, unsigned val);
} led_matrix_if;

//Task that drives the multiplexed 4x4 display on the xCORE-200 MC AUDIO board. Very low performance requirements so can be combined
#define LED_SCAN_TIME   200100   //2ms - How long each column is displayed. Any more than this and you start to see flicker
[[combinable]]void led_driver(server led_matrix_if i_leds, out port p_leds_col, out port p_leds_row){
    unsigned col_frame_buffer[4] = {0xf, 0xf, 0xf, 0xf};  //4 x 4 bitmap frame buffer scanning from left to right
                                                          //Active low drive hence initialise to 0b1111
    unsigned col_idx = 0;                                 //Index for above
    unsigned col_sel = 0x1;                               //Column select 0x8 -> 0x4 -> 0x2 -> 0x1
    timer t_scan;
    int scan_time_trigger;

    t_scan :> scan_time_trigger;                          //Get current time

    while(1){
        select{
            //Scan through 4 columns and output bitmap for each
            case t_scan when timerafter(scan_time_trigger + LED_SCAN_TIME) :> scan_time_trigger:
                p_leds_col <: col_sel;
                p_leds_row <: col_frame_buffer[col_idx];
                col_idx = (col_idx + 1) & 0x3;
                col_sel = col_sel << 1;
                if(col_sel > 0x8) col_sel = 0x1;
            break;

            //Sets a pixel at col, row (origin bottom left) to 0 or on
            case i_leds.set(unsigned col, unsigned row, unsigned val):
                row = row & 0x3;  //Prevent out of bounds access
                col = col & 0x3;
                if (val) {  //Need to clear corresponding bit (active low)
                    col_frame_buffer[col] &= ~(0x8 >> row);
                }
                else {      ///Set bit to turn off (active low)
                    col_frame_buffer[col] |= (0x8 >> row);
                }
            break;
        }
    }
}
User avatar
infiniteimprobability
XCore Legend
Posts: 1121
Joined: Thu May 27, 2010 10:08 am

Postby infiniteimprobability » Thu Mar 17, 2016 1:31 pm

Code: Select all

void app(client led_matrix_if i_leds){

  while(1){
    for(int x=0; x<4; x++){
      for(int y=0; y<4; y++){
        i_leds.set(x, y, 1);
        delay_milliseconds(100);
      }
    }
  }
}

int main(void)
{
  led_matrix_if i_leds;

  par{
    on tile[0]: app(i_leds);
    on tile[1]: led_driver(i_leds, p_leds_row, p_leds_col);
  }
  return 0;
}
paolovecchiotti
Junior Member
Posts: 6
Joined: Tue Mar 15, 2016 5:00 pm

Postby paolovecchiotti » Tue Mar 22, 2016 9:42 am

Thanks to all of you. The LEDs work fine with the provided code.
rutuja
Newbie
Posts: 1
Joined: Mon Mar 04, 2019 11:12 am

Postby rutuja » Mon Mar 04, 2019 11:20 am

Individually, when you work with the GPIO pins, you should explicitly characterize which tile ought to be utilized for the correct stick get to. As a matter of course, you will work with Tile # 0. For the Drove lattice, the LEDs are clung, electrical engineer.

Who is online

Users browsing this forum: No registered users and 0 guests