FXOS8700 SPI Woes

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FXOS8700 SPI Woes

Jump to solution
3,446 Views
warren1
Contributor I

I am attempting to use the FXOS8700 in SPI mode due to the faster read / write times associated with SPI (higher possible bus speed). I have set up the SPI bus to run with the following parameters which are consistent with the FXOS8700 data sheet:

CLK: 1 MHz

Order: MSB First

CPOL: Rising/Falling

CPHA: Sample/Setup

I have verified the above settings on an oscilloscope so I know that the bus is set up correctly. 

In order to get the FXOS into SPI mode, I tri-state the MISO pin before toggling the reset pin, and waiting the required time for the auto detection circuit to put the device into SPI mode. I then attempt to read the WHO_AM_I register and get the value 0x1e instead of 0xc7 which is what I would expect. Below is the code I am using to reset the device and read the WHO_AM_I register:

#define FXOS_MISO   26
#define FXOS_CS     11
#define FXOS_RST    3
void FXOSSPI()
{
    // Tri-state MISO
    pinMode( FXOS_MISO, TRI_STATE );
    delay( 10 );
    // Reset the FXOS
    digitalWrite( FXOS_RST, HIGH );
    digitalWrite( FXOS_RST, LOW );
    delay( 1 );
    // Set up the bus
    SPISettings _settings = SPISettings( 1000000, MSBFIRST, SPI_MODE0 );
    SPI1.beginTransaction( _settings );
    // Read WHO_AM_I
    uint8_t tx[3] = { ( 0x0D >> 1 ) & 0xFF, ( 0x0D << 7 ) & 0xFF , 0xFF };
    digitalWrite( FXOS_CS, LOW );
    for( uint8_t i = 0; i < 3; i++)
        buff[i] = SPI1.transfer( tx[i] );
    digitalWrite( FXOS_CS, HIGH );
    SPI1.end();
}

After I run that function I check the contents of buff using a break point and ICD, the contents of buff are:

buff[0] = 0xFF

buff[1] = 0xFF

buff[2] = 0x1E

Obviously, bytes 0, and 1 are DC because we are writing the R/W bits and the register address, but byte 2 should be 0xC7.  Not really sure what is going on here, I have looked at this many times under a scope, verified SPI register settings via ICD, slowed down the clock rate, etc. Still get the same results. Anybody else getting this problem? The only thing I can think of now is that my FXOS is damaged or something.

Labels (1)
Tags (1)
0 Kudos
1 Solution
3,151 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Warren,

I think I found where the problem is. You are not addressing the WHO_AM_I register (0x0D) correctly.

As shown in the datasheet:

 

Byte 0: R/W, ADDR[6], ADDR[5], ADDR[4], ADDR[3], ADDR[2], ADDR[1], ADDR[0]

Byte 1: ADDR[7], X, X, X, X, X, X, X

 

In your case tx[0] = ( 0x0D >> 1 ) & 0xFF while the correct way is tx[0] = 0x0D & 0x7F. Similarly tx[1] = ( 0x0D << 7 ) & 0xFF while the correct form is tx[1] = 0x0D & 0x80.

 

Here is my complete read a register function:

/******************************************************************************
* Read a byte from the FXOS8700CQ
* 
* Byte 0: 0,ADDR[6],ADDR[5],ADDR[4],ADDR[3],ADDR[2],ADDR[1],ADDR[0]
* Byte 1: ADDR[7],0,0,0,0,0,0,0
* Byte 2: 0,0,0,0,0,0,0,0
******************************************************************************/ 
unsigned char FXOS8700CQ_ReadRegister(unsigned char RegisterAddress)
{
 unsigned char i;
 
 CS_Enable;
 
 while (!(SPI0_S & SPI_S_SPTEF_MASK));
 SPI0_D = 0x7F & RegisterAddress;
 while (!(SPI0_S & SPI_S_SPRF_MASK));
 i = SPI0_D; 
 
 while (!(SPI0_S & SPI_S_SPTEF_MASK));
 SPI0_D = 0x80 & RegisterAddress;
 while (!(SPI0_S & SPI_S_SPRF_MASK));
 i = SPI0_D;
 
 while (!(SPI0_S & SPI_S_SPTEF_MASK));
 SPI0_D = 0x00; // Dummy byte
 while (!(SPI0_S & SPI_S_SPRF_MASK));
 i = SPI0_D;
CS_Disable;
 
 return i;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

I hope it helps.

Best regards,

Tomas 

View solution in original post

3 Replies
3,151 Views
warren1
Contributor I

Hi Tomas,

I can't believe I missed that! Just goes to show the value of having a fresh set of eyes on your code. Thank you, everything is working as planned now.

- Warren

0 Kudos
3,151 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

You are very welcome, Warren.

Very glad to hear it is working now!

Best regards,

Tomas

0 Kudos
3,152 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Warren,

I think I found where the problem is. You are not addressing the WHO_AM_I register (0x0D) correctly.

As shown in the datasheet:

 

Byte 0: R/W, ADDR[6], ADDR[5], ADDR[4], ADDR[3], ADDR[2], ADDR[1], ADDR[0]

Byte 1: ADDR[7], X, X, X, X, X, X, X

 

In your case tx[0] = ( 0x0D >> 1 ) & 0xFF while the correct way is tx[0] = 0x0D & 0x7F. Similarly tx[1] = ( 0x0D << 7 ) & 0xFF while the correct form is tx[1] = 0x0D & 0x80.

 

Here is my complete read a register function:

/******************************************************************************
* Read a byte from the FXOS8700CQ
* 
* Byte 0: 0,ADDR[6],ADDR[5],ADDR[4],ADDR[3],ADDR[2],ADDR[1],ADDR[0]
* Byte 1: ADDR[7],0,0,0,0,0,0,0
* Byte 2: 0,0,0,0,0,0,0,0
******************************************************************************/ 
unsigned char FXOS8700CQ_ReadRegister(unsigned char RegisterAddress)
{
 unsigned char i;
 
 CS_Enable;
 
 while (!(SPI0_S & SPI_S_SPTEF_MASK));
 SPI0_D = 0x7F & RegisterAddress;
 while (!(SPI0_S & SPI_S_SPRF_MASK));
 i = SPI0_D; 
 
 while (!(SPI0_S & SPI_S_SPTEF_MASK));
 SPI0_D = 0x80 & RegisterAddress;
 while (!(SPI0_S & SPI_S_SPRF_MASK));
 i = SPI0_D;
 
 while (!(SPI0_S & SPI_S_SPTEF_MASK));
 SPI0_D = 0x00; // Dummy byte
 while (!(SPI0_S & SPI_S_SPRF_MASK));
 i = SPI0_D;
CS_Disable;
 
 return i;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

I hope it helps.

Best regards,

Tomas 

%3CLINGO-SUB%20id%3D%22lingo-sub-821249%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EFXOS8700%20SPI%20Woes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-821249%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20am%20attempting%20to%20use%20the%20FXOS8700%20in%20SPI%20mode%20due%20to%20the%20faster%20read%20%2F%20write%20times%20associated%20with%20SPI%20(higher%20possible%20bus%20speed).%20I%20have%20set%20up%20the%20SPI%20bus%20to%20run%20with%20the%20following%20parameters%20which%20are%20consistent%20with%20the%20FXOS8700%20data%20sheet%3A%3C%2FP%3E%3CBLOCKQUOTE%20class%3D%22jive_macro_quote%20jive-quote%20jive_text_macro%22%3E%3CP%3ECLK%3A%201%20MHz%3C%2FP%3E%3CP%3EOrder%3A%20MSB%20First%3C%2FP%3E%3CP%3ECPOL%3A%20Rising%2FFalling%3C%2FP%3E%3CP%3ECPHA%3A%20Sample%2FSetup%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20have%20verified%20the%20above%20settings%20on%20an%20oscilloscope%20so%20I%20know%20that%20the%20bus%20is%20set%20up%20correctly.%26nbsp%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIn%20order%20to%20get%20the%20FXOS%20into%20SPI%20mode%2C%20I%20tri-state%20the%20MISO%20pin%20before%20toggling%20the%20reset%20pin%2C%20and%20waiting%20the%20required%20time%20for%20the%20auto%20detection%20circuit%20to%20put%20the%20device%20into%20SPI%20mode.%20I%20then%20attempt%20to%20read%20the%20WHO_AM_I%20register%20and%20get%20the%20value%200x1e%20instead%20of%200xc7%20which%20is%20what%20I%20would%20expect.%20Below%20is%20the%20code%20I%20am%20using%20to%20reset%20the%20device%20and%20read%20the%20WHO_AM_I%20register%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CBLOCKQUOTE%20class%3D%22jive_macro_quote%20jive-quote%20jive_text_macro%22%3E%3CDIV%3E%3CDIV%3E%23define%20FXOS_MISO%26nbsp%3B%26nbsp%3B%2026%3CBR%20%2F%3E%23define%20FXOS_CS%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%2011%3CBR%20%2F%3E%23define%20FXOS_RST%26nbsp%3B%26nbsp%3B%26nbsp%3B%203%3CBR%20%2F%3Evoid%20FXOSSPI()%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2F%20Tri-state%20MISO%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20pinMode(%20FXOS_MISO%2C%20TRI_STATE%20)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20delay(%2010%20)%3B%3C%2FDIV%3E%3CDIV%3E%20%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2F%20Reset%20the%20FXOS%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20digitalWrite(%20FXOS_RST%2C%20HIGH%20)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20digitalWrite(%20FXOS_RST%2C%20LOW%20)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20delay(%201%20)%3B%3C%2FDIV%3E%3CDIV%3E%20%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2F%20Set%20up%20the%20bus%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SPISettings%20_settings%20%3D%20SPISettings(%201000000%2C%20MSBFIRST%2C%20SPI_MODE0%20)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SPI1.beginTransaction(%20_settings%20)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2F%20Read%20WHO_AM_I%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20uint8_t%20tx%5B3%5D%20%3D%20%7B%20(%200x0D%20%26gt%3B%26gt%3B%201%20)%20%26amp%3B%200xFF%2C%20(%200x0D%20%26lt%3B%26lt%3B%207%20)%20%26amp%3B%200xFF%20%2C%200xFF%20%7D%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20digitalWrite(%20FXOS_CS%2C%20LOW%20)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20for(%20uint8_t%20i%20%3D%200%3B%20i%20%26lt%3B%203%3B%20i%2B%2B)%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20buff%5Bi%5D%20%3D%20SPI1.transfer(%20tx%5Bi%5D%20)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20digitalWrite(%20FXOS_CS%2C%20HIGH%20)%3B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20SPI1.end()%3B%3CBR%20%2F%3E%7D%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FBLOCKQUOTE%3E%3CP%3E%3C%2FP%3E%3CP%3EAfter%20I%20run%20that%20function%20I%20check%20the%20contents%20of%20buff%20using%20a%20break%20point%20and%20ICD%2C%20the%20contents%20of%20buff%20are%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CBLOCKQUOTE%20class%3D%22jive_macro_quote%20jive-quote%20jive_text_macro%22%3E%3CP%3Ebuff%5B0%5D%20%3D%200xFF%3C%2FP%3E%3CP%3Ebuff%5B1%5D%20%3D%200xFF%3C%2FP%3E%3CP%3Ebuff%5B2%5D%20%3D%200x1E%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3E%3C%2FP%3E%3CP%3EObviously%2C%20bytes%200%2C%20and%201%20are%20DC%20because%20we%20are%20writing%20the%20R%2FW%20bits%20and%20the%20register%20address%2C%20but%20byte%202%20should%20be%200xC7.%26nbsp%3B%20Not%20really%20sure%20what%20is%20going%20on%20here%2C%20I%20have%20looked%20at%20this%20many%20times%20under%20a%20scope%2C%20verified%20SPI%20register%20settings%20via%20ICD%2C%20slowed%20down%20the%20clock%20rate%2C%20etc.%20Still%20get%20the%20same%20results.%20Anybody%20else%20getting%20this%20problem%3F%20The%20only%20thing%20I%20can%20think%20of%20now%20is%20that%20my%20FXOS%20is%20damaged%20or%20something.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-821249%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EMagnetic%20Sensors%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-821252%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FXOS8700%20SPI%20Woes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-821252%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EYou%20are%20very%20welcome%2C%20Warren.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EVery%20glad%20to%20hear%20it%20is%20working%20now!%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBest%20regards%2C%3C%2FP%3E%3CP%3ETomas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-821251%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FXOS8700%20SPI%20Woes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-821251%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Tomas%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20can't%20believe%20I%20missed%20that!%20Just%20goes%20to%20show%20the%20value%20of%20having%20a%20fresh%20set%20of%20eyes%20on%20your%20code.%20Thank%20you%2C%20everything%20is%20working%20as%20planned%20now.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E-%20Warren%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-821250%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20FXOS8700%20SPI%20Woes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-821250%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Warren%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20think%20I%20found%20where%20the%20problem%20is.%20You%20are%20not%20addressing%20the%20WHO_AM_I%20register%20(0x0D)%20correctly.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAs%20shown%20in%20the%20datasheet%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EByte%200%3A%20R%2FW%2C%20ADDR%5B6%5D%2C%20ADDR%5B5%5D%2C%20ADDR%5B4%5D%2C%20ADDR%5B3%5D%2C%20ADDR%5B2%5D%2C%20ADDR%5B1%5D%2C%20ADDR%5B0%5D%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3EByte%201%3A%20ADDR%5B7%5D%2C%20X%2C%20X%2C%20X%2C%20X%2C%20X%2C%20X%2C%20X%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EIn%20your%20case%20tx%5B0%5D%20%3D%20(%200x0D%20%26gt%3B%26gt%3B%201%20)%20%26amp%3B%200xFF%20while%20the%20correct%20way%20is%20%3CSTRONG%3Etx%5B0%5D%20%3D%200x0D%20%26amp%3B%200x7F%3C%2FSTRONG%3E.%20Similarly%20tx%5B1%5D%20%3D%20(%200x0D%20%26lt%3B%26lt%3B%207%20)%20%26amp%3B%200xFF%20while%20the%20correct%20form%20is%26nbsp%3B%3CSTRONG%3Etx%5B1%5D%20%3D%200x0D%20%26amp%3B%200x80%3C%2FSTRONG%3E.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EHere%20is%20my%20complete%20read%20a%20register%20function%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CPRE%20class%3D%22language-c%20line-numbers%22%3E%3CCODE%3E%3CSPAN%20class%3D%22comment%20token%22%3E%2F******************************************************************************%0A*%20Read%20a%20byte%20from%20the%20FXOS8700CQ%0A*%20%0A*%20Byte%200%3A%200%2CADDR%5B6%5D%2CADDR%5B5%5D%2CADDR%5B4%5D%2CADDR%5B3%5D%2CADDR%5B2%5D%2CADDR%5B1%5D%2CADDR%5B0%5D%0A*%20Byte%201%3A%20ADDR%5B7%5D%2C0%2C0%2C0%2C0%2C0%2C0%2C0%0A*%20Byte%202%3A%200%2C0%2C0%2C0%2C0%2C0%2C0%2C0%0A******************************************************************************%2F%3C%2FSPAN%3E%20%0A%3CSPAN%20class%3D%22keyword%20token%22%3Eunsigned%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22keyword%20token%22%3Echar%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22token%20function%22%3EFXOS8700CQ_ReadRegister%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22keyword%20token%22%3Eunsigned%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22keyword%20token%22%3Echar%3C%2FSPAN%3E%20RegisterAddress%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22punctuation%20token%22%3E%7B%3C%2FSPAN%3E%0A%20%3CSPAN%20class%3D%22keyword%20token%22%3Eunsigned%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22keyword%20token%22%3Echar%3C%2FSPAN%3E%20i%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20%0A%20CS_Enable%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20%0A%20%3CSPAN%20class%3D%22keyword%20token%22%3Ewhile%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E!%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3ESPI0_S%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20SPI_S_SPTEF_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20SPI0_D%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0x7F%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20RegisterAddress%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20%3CSPAN%20class%3D%22keyword%20token%22%3Ewhile%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E!%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3ESPI0_S%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20SPI_S_SPRF_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20i%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20SPI0_D%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%20%0A%20%0A%20%3CSPAN%20class%3D%22keyword%20token%22%3Ewhile%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E!%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3ESPI0_S%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20SPI_S_SPTEF_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20SPI0_D%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0x80%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20RegisterAddress%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20%3CSPAN%20class%3D%22keyword%20token%22%3Ewhile%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E!%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3ESPI0_S%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20SPI_S_SPRF_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20i%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20SPI0_D%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20%0A%20%3CSPAN%20class%3D%22keyword%20token%22%3Ewhile%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E!%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3ESPI0_S%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20SPI_S_SPTEF_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20SPI0_D%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22number%20token%22%3E0x00%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22comment%20token%22%3E%2F%2F%20Dummy%20byte%3C%2FSPAN%3E%0A%20%3CSPAN%20class%3D%22keyword%20token%22%3Ewhile%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22operator%20token%22%3E!%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E(%3C%2FSPAN%3ESPI0_S%20%3CSPAN%20class%3D%22operator%20token%22%3E%26amp%3B%3C%2FSPAN%3E%20SPI_S_SPRF_MASK%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E)%3C%2FSPAN%3E%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20i%20%3CSPAN%20class%3D%22operator%20token%22%3E%3D%3C%2FSPAN%3E%20SPI0_D%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0ACS_Disable%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%20%0A%20%3CSPAN%20class%3D%22keyword%20token%22%3Ereturn%3C%2FSPAN%3E%20i%3CSPAN%20class%3D%22punctuation%20token%22%3E%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22punctuation%20token%22%3E%7D%3C%2FSPAN%3E%3CSPAN%20class%3D%22line-numbers-rows%22%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3CSPAN%3E%E2%80%8D%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3EI%20hope%20it%20helps.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBest%20regards%2C%3C%2FP%3E%3CP%3ETomas%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E