NXT enhanced firmware

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXT enhanced firmware

Post by afanofosc »

In theory, you ought to be able to use the FastI2C support in the enhanced NBC/NXC firmware using NXT-G. The API function that Matt posted:

Code: Select all

SetI2COptions(S1, I2C_OPTION_FAST);
simply sets a global variable to a value other than zero.

Code: Select all

#define I2C_OPTION_FAST      0x08 /*!< Fast I2C speed */
That variable is then ORed with the specified port just before calling the CommLSWrite system call function.

Code: Select all

  or __CLSWArgs0.Port, _port, __LSWriteOptionsVar \
  mov __CLSWArgs0.ReturnLen, _retlen \
  mov __CLSWArgs0.Buffer, _buffer \
  syscall CommLSWrite, __CLSWArgs0 \
So you could write an NXT-G block that uses the CommLSWrite system call function and allow the value in the Port field of the structure that you pass into this system call function to have a value beyond 0..3 (i.e., the range of valid port numbers). I don't know how the existing NXT-G block that lets you do I2CWrites is written but it probably could be "fixed" if it currently enforces a strict limit on the port value. If you wanted to use Fast I2C on S1 then you would pass in 0x08 (i.e., 0x0 | 0x08). If you wanted to use Fast I2C on S2 then you would pass in 0x09 (1+8), etc...

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
peter-cocteau
Posts: 26
Joined: 04 Dec 2011, 12:12

Re: NXT enhanced firmware

Post by peter-cocteau »

Thanks John,

well, I have read your answer several times but I didn't understand a lot. I just begin to use I2C, I read Mindsensor Touch Panel values with NXT-G I2C block but that's all.

At first I don't understand what means 0x08, I take a look to Superproboards i2C adress document and adress look like 00-07H, is it hexadecimal ? 0x08 is the value to transfer to I2C device? What means "0x" ?

In fact I would like to see how much Hitechnic Superproboard and Mindsensor touch panel I2C communication speed can be increase.

As you see I have many things to learn. :)

Peter.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXT enhanced firmware

Post by HaWe »

0x means HEX
0x8 =8
0xf=15
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXT enhanced firmware

Post by afanofosc »

Peter,

If you are not familiar with how to create an NXT-G block then you may need some assistance from someone like Steve H or others who are really good at that. But what you need is an I2CWrite block that would allow you to set the Port input value to something other than 0, 1, 2, or 3 (or 1-4 if the block internally subtracts one, which I don't know). The enhanced NBC/NXC firmware implements Fast I2C by looking for 8 (decimal or hexadecimal) added to the port number (0-3). In the enhanced firmware when you say "write to I2C device on port 8" it switches into fast I2C mode and writes to the device on port 0. 9 -> fast i2c on port 1, 10 -> fast i2c on port 2, 11 -> fast i2c on port 3.

So depending on how the guts of the I2CWrite block in NXT-G is written it may just work or it may not allow values > 3 for the port, in which case you'll need someone like Steve H or someone from HiTechnic like Gus to write an I2CWrite block that would allow turning on Fast I2C mode for the enhanced NBC/NXC firmware by adding 8 to the specified port before calling the CommLSWrite system call.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
peter-cocteau
Posts: 26
Joined: 04 Dec 2011, 12:12

Re: NXT enhanced firmware

Post by peter-cocteau »

John,

yes, NXT-G I2C block seems restricted to (1-4). I would really like to create my own blocks, I will have a look to this subject soon.
BTW Gus already helped me, and Hitechnic add a restart wave function to Superpro board firmware and NXT-G block, I received it yesterday.

Peter.
peter-cocteau
Posts: 26
Joined: 04 Dec 2011, 12:12

Re: NXT enhanced firmware

Post by peter-cocteau »

It's christmas again !!! Gus send me new NXT-G block with fast I2C support when using your firmware.

Gus said it took 2,4 ms instead of 10ms what is the best new of the week! it changes many of my views for my next music machine. That's very cool!

Si I've took 5 minutes to try to download your firmware, I found 3 files in the zip: "..._107.rfw" "..._131.rfw" and "..._131_20111019_1659.rfw"

Which one I have to download as firmware ? I think I won't have any problem by downloading it thru NXT-G as I do for other Firmware versions.

Thanks a lot!!! fast i2C wil change my life! ;)

Peter.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXT enhanced firmware

Post by afanofosc »

I would grab the latest firmware from the test_releases folder:

http://bricxcc.sourceforge.net/test_rel ... 6_1512.rfw

I will upload a newer build tonight (!) that includes Nicolas' faster text drawing code. I keep forgetting to do that, mea culpa.

Just remember that in fast I2C mode you spend much more time in the Command module than the firmware is normally designed to spend so other firmware modules will be a bit starved for time. In some cases that's not a huge deal but in other cases it is much less than ideal. For example, if you wanted to use fast I2C on port 1 but normal I2C on other ports and you wanted to execute the normal I2C at the same time (separate thread) as the fast I2C then probably your normal I2C transaction would fail since it depends on the Lowspeed module getting a chance to execute about once ever millisecond. The fast I2C transaction would consume as much as 2.5 ms (or longer) in the Command module before it yielded to the Lowspeed module and other firmware modules. I am not certain and haven't tested this but I think that would mess up the firmware's attempt to complete the normal I2C transaction.

You should be able to download the enhanced firmware from within the LEGO MINDSTORMS NXT software without any trouble.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
peter-cocteau
Posts: 26
Joined: 04 Dec 2011, 12:12

Re: NXT enhanced firmware

Post by peter-cocteau »

Thanks John.

No problem for command module. My music programs make things one by one to get best time accuracy.

Peter.
pepijndevos
Posts: 175
Joined: 28 Dec 2011, 13:07
Location: Gelderland, Netherlands
Contact:

Re: NXT enhanced firmware

Post by pepijndevos »

afanofosc wrote:At the moment I have not yet implemented firmware-level support for the GPS data mode. It's just not been high enough on the priority list yet.

John Hansen
Aww, I got all excited when I saw the flag. I think it would be a great addition. This stuff is just so... painfully long: http://freelug.org/spip.php?page=articl ... C%2520code

Is the mentioned array limitation still accurate?
//Workarround buffer of 58 bytes, because nxc is only able to read max 58 bytes
-- Pepijn
http://studl.es Mindstorms Building Instructions
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXT enhanced firmware

Post by afanofosc »

What is the source of the comment that says NXC is only able to read 58 bytes?

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests