Need help with the simple custom board

Technical questions regarding the XTC tools and programming with XMOS.
AlexAdvice
XCore Addict
Posts: 150
Joined: Sun Feb 23, 2014 11:30 am

Post by AlexAdvice »

segher wrote: Your next steps would be to run a simple program (something
that blinks a LED perhaps); run something that uses USB
(maybe the HID demo); and try to program one of those
to flash.
It is too complicated for me to make the program from zero - I'm familiar in PIC/ARM programming, but XTimeComposer and XMOS is so totalyy different from Keil/Mplab....

So I try to get the Reference Design with minor chahges.
I take USB Audio 2.0 Ref.Desing, latest version (6.6.0), download the latest Composer.

I make changes in .xn file - due to a differend case (TQ48 instead of 128) and other flash (AT25DF041A instead onf 25FS010).

But when I try to compile it, I got 2 errors, that I can't find the source:

Code: Select all

xmake CONFIG=2ioxx all 
Using modules: module_usb_shared module_xud module_usb_audio module_spdif_tx module_spdif_rx module_usb_midi module_dfu module_usb_device module_queue module_xassert
Creating app_usb_aud_l1_2ioxx.xe
xmap: Error: Symbol p_for_mclk_count is a duplicate port declaration.
xmap: Error:   previously declared as p_usb_rst.
xmap: Warning: port "XS1_PORT_8A" on tile[0] is not connected to any pins in this package.
xmap: Warning: port "XS1_PORT_8C" on tile[0] is not connected to any pins in this package.
xmake[1]: *** [bin/2ioxx/app_usb_aud_l1_2ioxx.xe] Error 1
xmake: *** [bin/2ioxx/app_usb_aud_l1_2ioxx.xe] Error 2

I changed only .xn file, and port32a.h (see attachnent).
Can somebody check if I change CPU in .xn correctly?
You do not have the required permissions to view the files attached to this post.
User avatar
lilltroll
XCore Expert
Posts: 956
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Post by lilltroll »

About the RST_N and TRST_N

I was working with a logic-analyser connected to the XTAG last week.

XMOS introduced the pin MSEL some time ago, and this solved the race problem between the MODE pins and the reset pin.

The XMOS chip reads the MODE pin when reset is released. That means that the MODE pins must be set before reset changes.

By connecting the XTAG RST_N to both XMOS chip RST_N and TRST_N and connecting the XTAG MSEL/TRST_N to the mode pins (together with the newer toolchains), the MSEL is set a few microseconds before RESET_N changes. This ensures that the chip always waits for XTAG boot when a XTAG is connected.
AlexAdvice
XCore Addict
Posts: 150
Joined: Sun Feb 23, 2014 11:30 am

Post by AlexAdvice »

OK friends, it looks like I'v found where it ws mistake after my changes in USB Audio application, but even afre it not works.
So, I comment it's "main" and wrote my:

Code: Select all

#define PORT32A_INPUT(X) {asm("peek %0, res[%1]":"=r"(X):"r"(XS1_PORT_32A));}
#define PORT32A_OUTP(X)  {asm("out res[%0], %1"::"r"(XS1_PORT_32A),"r"(X));}

void led_flash(){
 timer t;
 unsigned time;
 unsigned tmp;

 while(1){
     PORT32A_INPUT(tmp);
     tmp |= 0x10;      // this will flash
     tmp &=(~0x20);  // this will flash opposite
     tmp &=(~0x08);  // this will not lit
     PORT32A_OUTP(tmp);

     t :> time;                     // 1 sec delay
     time += 100000000;
     t when timerafter(time) :> int _;

     PORT32A_INPUT(tmp);
     tmp |= 0x20;
     tmp &=(~0x10);
     PORT32A_OUTP(tmp);

     t :> time;                         // 1 sec delay
     time += 100000000;
     t when timerafter(time) :> int _;
 }
}
int main(){
  par{
    on tile[0]: led_flash();
  }
  return 0;
}
And my 1st XMOS program works!
Later, I changed in .xn AT25FS010 to AT25DF041A and write program to flash.
It works without XTAG after power down.
Yahoo!!!! Except USB PHY - my 1st XMOS HW is OK.
Many thanks to all who help or try to help.

But, don't ralax, now I will disturb you with the software!

At first - can you suggest very simple and small USB HID application? Just to test USB PHY?
AlexAdvice
XCore Addict
Posts: 150
Joined: Sun Feb 23, 2014 11:30 am

Post by AlexAdvice »

Hello friends.

It sees that I found where the problem, but I can't solve it without your help.

When I run my program, I saw correct pulses at I2S bus, but USB not works - PHY's reset pin is always "0".
Then I found some things in the source code, and to be sure - I make a new clean workspace in XTimeComposer and imported USB-Audio-2.0-Device-Reference-Design-Software(6.6.0).zip without any changes.
Then I compile the project app_usb_aud_l1 in 2ioxx mode - and I saw exactly the same!

File main.xc:

Yellow square at the left at the line #include "xud.h" with the message "Unresolved inclusion".


Then:

Code: Select all

/* L/G Series needs a port to use for USB reset */
#if (XUD_SERIES_SUPPORT != XUD_U_SERIES) && defined(PORT_USB_RESET)
/* This define is checked since it could be on a shift reg or similar */
on tile[XUD_TILE] : out port p_usb_rst  = PORT_USB_RESET;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this line is not active
#else
/* Reset port not required for U series due to built in Phy */
#define p_usb_rst   null
^^^^^^^^^^^^^^^^^^ this line is active
#endif


So, the compiler make the program not for L1 and does not use external USB PHY!

To check this, I change the line in port32A.h:
#define P32A_USB_RST 0x01 /* ULPI rst line */
to
#define P32A_USB_RST 0x0v1 /* ULPI rst line */

Then I compile the program without any error! So I was right - It compile not for L1.
Again - this was without any changes, in clean just downloaded and installed latest Composer, and just downloaded and imported latest version of the reference design!

I hope if XMOS peoples will help to repair the reference design, my program will also start to work, so - heeeelppppppp!!!!!
User avatar
Ross
Verified
XCore Legend
Posts: 1179
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

AlexAdvice wrote:
So, the compiler make the program not for L1 and does not use external USB PHY!

To check this, I change the line in port32A.h:
#define P32A_USB_RST 0x01 /* ULPI rst line */
to
#define P32A_USB_RST 0x0v1 /* ULPI rst line */

Then I compile the program without any error! So I was right - It compile not for L1.
Again - this was without any changes, in clean just downloaded and installed latest Composer, and just downloaded and imported latest version of the reference design!

I hope if XMOS peoples will help to repair the reference design, my program will also start to work, so - heeeelppppppp!!!!!
That define is not used in the code, so this test is invalid.

You seem to have moved the USB phy reset line to D55 (Port 32 bit[6]) but not modified the code to account for this.

The reference design software v6.6.6 operates fully on the XMOS L-series reference designs - it does not need repair.
AlexAdvice
XCore Addict
Posts: 150
Joined: Sun Feb 23, 2014 11:30 am

Post by AlexAdvice »

Ross wrote:You seem to have moved the USB phy reset line to D55 (Port 32 bit[6]) but not modified the code to account for this.
Hello Ross,

thank you for your reply.
Yes, I want to move ULPI Rest signal to XOD66, as XOD49 does not exists in 48 pin package.
Where I should chage this definition?
User avatar
Ross
Verified
XCore Legend
Posts: 1179
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

AlexAdvice wrote:
Ross wrote:You seem to have moved the USB phy reset line to D55 (Port 32 bit[6]) but not modified the code to account for this.
Hello Ross,

thank you for your reply.
Yes, I want to move ULPI Rest signal to XOD66, as XOD49 does not exists in 48 pin package.
Where I should chage this definition?
You can use bit[0] on any port without modding the software (apart from the XN file) or see the "rstMask" param to XUD_Manager() here: https://www.xmos.com/published/xuddg?secure=1
AlexAdvice
XCore Addict
Posts: 150
Joined: Sun Feb 23, 2014 11:30 am

Post by AlexAdvice »

#if (AUDIO_CLASS==2)
XUD_Manager(c_xud_out, ENDPOINT_COUNT_OUT, c_xud_in, ENDPOINT_COUNT_IN,
c_sof, epTypeTableOut, epTypeTableIn, p_usb_rst,
clk,1, XUD_SPEED_HS, pwrConfig);


This ?
User avatar
Ross
Verified
XCore Legend
Posts: 1179
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

That's it