How to drive LED array on XK-AUDIO-216-MC-AB?

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
cjf1699
Active Member
Posts: 48
Joined: Fri Mar 16, 2018 2:30 pm

How to drive LED array on XK-AUDIO-216-MC-AB?

Postby cjf1699 » Sun Apr 08, 2018 8:19 am

Dear Everyone,
I'm working on the xCORE-200 Multichannel Audio Platform, which has a 4*4 LED-array on it. The LED array is driven by eight signals each controlling one of 4 rows and 4 columns. Rows are controlled by a 4-bit port XS1_PORT_4C, and columns are controlled by a 4-bit port XS1_PORT_4D.According to the XMOS progamming guide, I declared 2 out ports as global variables like this:

Code: Select all

on tile[0]: out port led_row = XS1_PORT_4C;
on tile[0]: out port led_col = XS1_PORT_4D;

And I called them like this in the i2s_loopback function of example AN00162:

Code: Select all

 case i2s.receive(size_t index, int32_t sample):
      samples[index] = sample;
      if(sample == 0){
          led_row <: 0x0E;
          led_col <: 0x0E;
      }                                      // want to active the led of row0 ,col0
     // xscope_int(0, sample);
      break;

    case i2s.send(size_t index) -> int32_t sample:
      sample = samples[index];
   //   xscope_int(1, sample);
      if(sample != 0){
                led_row <: 0x07;
                led_col <: 0x07;                // want to active the led of row3 ,col3
            }
      break;

However, nothing happened to the leds, they weren't actived. What's wrong in it?
Thank you very much!
cjf
User avatar
mon2
XCore Legend
Posts: 1162
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Postby mon2 » Sun Apr 08, 2018 11:32 am

You will have to learn how to use the search feature for this user forum. The same question has been asked and replied to many times.

viewtopic.php?f=3&t=6314&p=31562&hilit=Led+audio&sid=11303981924bf855f7bf0fbcfac8ae50#p31562
cjf1699
Active Member
Posts: 48
Joined: Fri Mar 16, 2018 2:30 pm

Postby cjf1699 » Sun Apr 08, 2018 4:13 pm

mon2 wrote:You will have to learn how to use the search feature for this user forum. The same question has been asked and replied to many times.

viewtopic.php?f=3&t=6314&p=31562&hilit=Led+audio&sid=11303981924bf855f7bf0fbcfac8ae50#p31562

Thank you for your answer. But I still encoutered some problems...
According to the hardware manual map, both rows and columns are actived low. So I added codes like this:

Code: Select all

case i2s.receive(size_t index, int32_t sample):
      samples[index] = sample;

      if(sample != 0){              //turn on D25
                  led_row <: 0x7;
       
          led_col <: 0x7;
      }

     // xscope_int(0, sample);
      break;

    case i2s.send(size_t index) -> int32_t sample:
      sample = samples[index];
   //   xscope_int(1, sample);

      if(sample != 0){              //turn on D10
               
               led_row <: 0xE;
             
               led_col <: 0xE;
           

      break;

However ,weird things happened. When I run the project, it appeared like this:
D11~D13, D22~D24 were on, while D10 and D25 were "half on"..
I don't know why. Perhaps I didn't active the right pins?
Thanks a lot!
Image
Last edited by cjf1699 on Sun Apr 08, 2018 4:41 pm, edited 1 time in total.
User avatar
mon2
XCore Legend
Posts: 1162
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Postby mon2 » Sun Apr 08, 2018 4:40 pm

Modify the code to view the results of the D25 LED as follows and post your results:

Code: Select all

case i2s.receive(size_t index, int32_t sample):
      samples[index] = sample;

      if(sample != 0){              //turn on D25
                  led_row <: 0x7;
                  led_col <: 0x7;
                  while(1); // wait forever to view the results
      }

     // xscope_int(0, sample);
      break;
cjf1699
Active Member
Posts: 48
Joined: Fri Mar 16, 2018 2:30 pm

Postby cjf1699 » Mon Apr 09, 2018 3:24 am

Well ,every led except D25 was on.

Image

Moreover, the music can't be looped back with a "while(1)" exsiting.
User avatar
mon2
XCore Legend
Posts: 1162
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Postby mon2 » Mon Apr 09, 2018 3:30 am

Smelling a documentation error...try this and post your results:

Code: Select all

case i2s.receive(size_t index, int32_t sample):
      samples[index] = sample;

      if(sample != 0){              //turn on D25
                  led_row <: 0x7;
                  led_col <: 0x8;
                  while(1); // wait forever to view the results
      }

     // xscope_int(0, sample);
      break;


Yes, the music will not play due to the permanent loop (stop condition). This is only to assist in debugging the LED status.
cjf1699
Active Member
Posts: 48
Joined: Fri Mar 16, 2018 2:30 pm

Postby cjf1699 » Mon Apr 09, 2018 4:12 am

When I wrote the codes this way:

Code: Select all

case i2s.receive(size_t index, int32_t sample):
      samples[index] = sample;

      if(sample != 0){              //turn on D25
                  led_row <: 0x7;
       
          led_col <: 0x8;
      }

     // xscope_int(0, sample);
      break;

    case i2s.send(size_t index) -> int32_t sample:
      sample = samples[index];
   //   xscope_int(1, sample);

      if(sample != 0){              //turn on D10
               
               led_row <: 0xE;
             
               led_col <: 0x1;
           

      break;

Shows like this:

Image
This time, both D25 and D10 are on.
The fact turns out that the row is actived low but the column is actived high.....

Who is online

Users browsing this forum: Bogdanljc, CanadafinU and 25 guests