xu316 port output current strength and input Schmitt trigger mode settings

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
paul.yuan
Member
Posts: 9
Joined: Mon Jun 28, 2021 4:39 am

xu316 port output current strength and input Schmitt trigger mode settings

Post by paul.yuan »

Hello.
I'm running the I2S_slave thread on the XU316, but find that the received data is error-prone; lrclk and sclk don't match.
I want to change the output drive current of xu316 to be larger, change it to 12mA, may I ask which function to call to set it;
In addition, I also want to change the input port to smitte trigger mode, and which function needs to be called.
thanks.
User avatar
CousinItt
Respected Member
Posts: 367
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

This sounds a bit odd - is there a clock configuration problem or something like that?

The data sheet says to use the SETC instruction (there should be a function supporting it in C/xC) :
MODE_SETPADCTRL Mode bits 0x0006. Sets the pad options according to the value of bits 23..18. Bits 19 and 18 set the pull resistor (00 for none; 01 for weak pull-up; 10 for weak pull-down; or 11 for weak buskeep.). Bits 21 and 20 set the drive strength (00 for 2mA; 01 for 4mA; 10 for 8mA; or 11 for 12mA). Bit 22 enables slew-rate control. Bit 23 enables the Schmitt-Trigger.
paul.yuan
Member
Posts: 9
Joined: Mon Jun 28, 2021 4:39 am

Post by paul.yuan »

The problem of I2S_Salve: I double checked the code and there is no problem (the code is attached);
No problem was found with a 500M logic analyzer.
I did not find the MODE_SETPADCTRL macro definition in the SDK;
I'm not sure how to use the setc command:

I don't know if the following code can set X0_1A0 to Schmitt trigger input mode:
on tile[0] : buffered in port:1 p_1a = XS1_PORT_1A;
asm ("setc res[%0], %1"::"r"(p_1a ),"r"(1<<22));

Also: please help me to confirm:
Can each IO port of XU316 be set to Schmitt trigger input mode? Because in the fourth section of the datasheet: Signal Description and GPIO,
The attributes of these IO ports are not marked with ST here
User avatar
CousinItt
Respected Member
Posts: 367
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

Which version of the I2S library are you using? There was a bug in i2s_frame_slave_init_ports() which was fixed in rev 4.0.0rc1.

In xs3a_user.h you can find: #define XS1_SETC_MODE_SETPADCTRL 0x6

In xcore_port_impl.h there are plenty of examples of SETC, using _XCORE_RESOURCE_SETCI(__res, __c). There's also _XCORE_INLINE void __xcore_resource_setc(resource_t __r, uint32_t __word). Both are defined in xcore_resource_impl.h.

So you could try something like this:

Code: Select all

_XCORE_INLINE void __xcore_port_set_pad_ctrl(resource_t __p, uint32_t __val)
{
  _XCORE_RESOURCE_SETCI(__p, XS1_SETC_MODE_SETPADCTRL | __val);
}
... and just set the bits of interest. Note there's no masking of the mode bits in __val so this isn't particularly safe. Also I don't have any test hardware, so try this at your own risk!

The data sheet says (my emphasis)
Note that all GPIO have optional pull-down, pull-up, and Schmitt triggers.
I'm guessing ST indicates the Schmitt trigger is a fixed feature of an input, rather than an option.
User avatar
CousinItt
Respected Member
Posts: 367
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

Having looked at the architecture doc I realise that SETCI shouldn't be used as it only accepts a 16-bit immediate operand. Try using __xcore_resource_setc() instead, something like:

Code: Select all

_XCORE_INLINE void __xcore_port_set_pad_ctrl(resource_t __p, uint32_t __val)
{
  __xcore_resource_setc(__p, XS1_SETC_MODE_SETPADCTRL | (__val & 0xFFFF0000UL));
}
paul.yuan
Member
Posts: 9
Joined: Mon Jun 28, 2021 4:39 am

Post by paul.yuan »

Attached is audio_ Slave thread code
Last edited by paul.yuan on Fri Sep 30, 2022 2:22 pm, edited 1 time in total.
paul.yuan
Member
Posts: 9
Joined: Mon Jun 28, 2021 4:39 am

Post by paul.yuan »

0x00006 is the address of the mode setting register?
You do not have the required permissions to view the files attached to this post.
paul.yuan
Member
Posts: 9
Joined: Mon Jun 28, 2021 4:39 am

Post by paul.yuan »

After I add # include "xcore_port_impl. h" to the xc file to be compiled,
The following compilation error prompts will appear (the relevant files are attached):
In file included from C:\Program Files (x86)\XMOS\XTC\15.1.4\target/include/xcore/_support\xcore_port_impl.h:13:
C:\Program Files (x86)\XMOS\XTC\15.1.4\target/include\xcore/_support/xcore_resource_impl.h:22:14: error: cannot declare pointer to function
typedef void(*__xcore_interrupt_callback_t)(void);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\XMOS\XTC\15.1.4\target/include\xcore/_support/xcore_resource_impl.h:23:14: error: cannot declare pointer to function
typedef void(*__xcore_select_callback_t)(void);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\XMOS\XTC\15.1.4\target/include\xcore/_support/xcore_resource_impl.h:27:68: error: void * pointer must be declared as unsafe
_XCORE_INLINE void __xcore_resource_setup_callback(resource_t __r, void *__data, void(*__func)(void), uint32_t __type) _XCORE_NOTHROW
^~~~~~~~~~~~
C:\Program Files (x86)\XMOS\XTC\15.1.4\target/include\xcore/_support/xcore_resource_impl.h:27:82: error: cannot declare pointer to function
_XCORE_INLINE void __xcore_resource_setup_callback(resource_t __r, void *__data, void(*__func)(void), uint32_t __type) _XCORE_NOTHROW

^~~~~~~~~~~~~~~~~~~
You do not have the required permissions to view the files attached to this post.
User avatar
CousinItt
Respected Member
Posts: 367
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

0x00006 is the address of the mode setting register?
No 0x0006 is the value of the mode setting for the SETC instruction for configuring the port. See the section "Resources and their configuration" in the relevant XU316 data sheet, and the description of the SETC instruction and the section on "Port Configuration" (15.2) in the XS3 architecture document.
User avatar
CousinItt
Respected Member
Posts: 367
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

paul.yuan wrote: Fri Sep 30, 2022 2:19 pm After I add # include "xcore_port_impl. h" to the xc file to be compiled,
The following compilation error prompts will appear (the relevant files are attached):
....
Maybe xcore_port_impl.h is not intended to be included directly; it could be that some other definitions are needed to pave the way. I searched for other headers that include that file (directly or indirectly) and I found xcore_all.h, which looks like a top-level header, considering its name and content. Perhaps you should try including that header file instead.