Tle5012b ssc via tle987x evalboard,

Announcements

Webinar: Integrated solutions for smaller, simpler low-voltage motor control design.
Join the webinar to experience!

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User17857
Level 3
Level 3
First like received
Hello everyone,

I use tle 987x evalboard to comunicate via ssc with tle5012b mangetic angle sensor. Is there anyone that have ssc comunatication example code or document with tle5012b and tle 987x evalboard ?

Regards,
14 Replies
Fiz
Moderator
Moderator
Moderator
First like received 50 replies posted 25 replies posted
Hello Muatrazi,

Unfortunately we do not have any example code or document to establish communication between the TLE987x and TLE5012b.
Have you already tried to make them to talk over 3-wire SPI? You could also try using PWM .

Best,
Fiz
0 Likes
User17857
Level 3
Level 3
First like received
Hello Fiz,

I have not tried 3 wire spi but i will. I have tried with arduino thanks to github arduino library of tle5012b. But it did not work. I do not know what is wrong 🙂

Kind regards
Murat.
0 Likes
Fiz
Moderator
Moderator
Moderator
First like received 50 replies posted 25 replies posted
Hello Murat,

Let us know if you have any troubles! Where you able to establish any communication?
Did you try the PWM interface as well?

Best,
Fiz
0 Likes
User17857
Level 3
Level 3
First like received
Hello fiz,

I could have a communication between arduino uno and tle5012b. Now i will rewrite a library for tle987x and i am sure it will work. I will let you know when i am done.

Kind Regards
Murat
0 Likes
User17857
Level 3
Level 3
First like received
Hello Fiz,

I have some doubts about ssc properties in order to communicate between tle987 and tle5012b e3005. Do you think that the adjustment that is attached below for tle5012b on tle987 is correct ?

3878.attach3879.attach
0 Likes
Fiz
Moderator
Moderator
Moderator
First like received 50 replies posted 25 replies posted
Hi Murat,


did you look into the XMC2go sensor shield with the TLE55012b? They have some examples using SSC.

https://www.infineon.com/cms/en/product/evaluation-boards/tle5012b_e5000_ms2go/#!tools

they are using a GUI where you can easily establish communication, or you can check the software on github.
https://github.com/Infineon/TLE5012-Magnetic-Angle-Sensor

There you can also find some help how to configure the SSC.

Best,
Fiz
0 Likes
User17857
Level 3
Level 3
First like received
Hi Fiz,

I have worked with the library you sent. I am working on arm keil. I am trying to reconfigure the library for tle987. I configured the the ssc properties like in the library but it did not work. So i am asking this.
0 Likes
User17857
Level 3
Level 3
First like received
Hello Fiz,

I rewrote tle5012b arduino library for tle987x eval board. My code is below. And i have used the configuration which is below for the ssc communication. I have used 470 ohm resistor for mosi and miso
before connecting the ssc data pins. I supply tle5012b e3005 with vddexit which is 5v. I have used p0.1 as chip select pin. Any help will be appreciated.

#include "tle_device.h"
#include "eval_board.h"
void setup();
double calculateAngleSpeed(double angRange, int16_t rawAngleSpeed, uint16_t firMD, uint16_t predictionVal);
uint8_t crcCalc(uint8_t* crcData, uint8_t length);
double angleValue;
uint8_t crc8(uint8_t *data, uint8_t length);
uint8_t getSecondByte(uint16_t twoByteWord);
uint8_t getFirstByte(uint16_t twoByteWord);
void enableSensor();
void disableSensor();
enum errorTypes getAngleValue();
enum errorTypes readFromSensor(uint16_t command, uint16_t *data);

/*****************************************************************************/
/** SSC1: sends one byte (0xAA) as SPI master @ 1 Mbaud **/
/*****************************************************************************/
/** program SSC1 to operate at 1 Mbaud **/
/** SSC1 sends one byte at P0.3 (CLK), P0.2 (MTSR) **/
/*****************************************************************************/

#define TLE5012B_H

// Sensor registers
#define READ_SENSOR 0x8000 //!< base command for read
#define WRITE_SENSOR 0x5000 //!< base command for write
#define READ_BLOCK_CRC 0x8088 //!< initialize block CRC check command



#define SYSTEM_ERROR_MASK 0x4000 //!< System error masks for safety words
#define INTERFACE_ERROR_MASK 0x2000 //!< Interface error masks for safety words
#define INV_ANGLE_ERROR_MASK 0x1000 //!< Angle error masks for safety words

#define CRC_POLYNOMIAL 0x1D //!< values used for calculating the CRC
#define CRC_SEED 0xFF
#define CRC_NUM_REGISTERS 0x0008 //!< number of CRC relevant registers
#define MAX_REGISTER_MEM 0x0030 //!< max readable register values buffer

#define DELETE_BIT_15 0x7FFF //!< Value used to delete everything except the first 15 bits
#define CHANGE_UINT_TO_INT_15 0x8000 //!< Value used to change unsigned 16bit integer into signed
#define CHECK_BIT_14 0x4000 //!<
#define GET_BIT_14_4 0x7FF0 //!<

#define DELETE_7BITS 0x01FF //!< values used to calculate 9 bit signed integer sent by the sensor
#define CHANGE_UNIT_TO_INT_9 0x0200 //!< Value used to change unsigned 9bit integer into signed
#define CHECK_BIT_9 0x0100

#define POW_2_15 32768.0 //!< values used to for final calculations of angle speed, revolutions, range and value
#define POW_2_7 128.0 //!<
#define ANGLE_360_VAL 360.0

#define TEMP_OFFSET 152.0 //!< values used to calculate the temperature
#define TEMP_DIV 2.776

//!< Prints a binary number with leading zeros (Automatic Handling)
#define PRINTBIN(Num) for (uint32_t t = (1UL<< (sizeof(Num)*8)-1); t; t >>= 1) Serial.write(Num & t ? '1' : '0');
//!< Prints a binary number with leading zeros (Automatic Handling) with space
#define PRINTBINS(Num) for (uint32_t t = (1UL<< (sizeof(Num)*8)-1); t; t >>= 1) Serial.write(Num & t ? " 1 " : " 0 ");

/*!
* Error types from safety word
*/
enum errorTypes
{
NO_ERROR = 0x00, //!< NO_ERROR = Safety word was OK
SYSTEM_ERROR = 0x01, //!< SYSTEM_ERROR = over/under voltage, VDD negative, GND off, ROM defect
INTERFACE_ACCESS_ERROR = 0x02, //!< INTERFACE_ACCESS_ERROR = wrong address or wrong lock
INVALID_ANGLE_ERROR = 0x03, //!< INVALID_ANGLE_ERROR = NO_GMR_A = 1 or NO_GMR_XY = 1
ANGLE_SPEED_ERROR = 0x04, //!< ANGLE_SPEED_ERROR = combined error, angular speed calculation wrong
CRC_ERROR = 0xFF //!< CRC_ERROR = Cyclic Redundancy Check (CRC), which includes the STAT and RESP bits wrong
};

/*!
* Set the UPDate bit high (read from update buffer) or low (read directly)
*/
enum updTypes
{
UPD_low = 0x0000, //!< read normal registers
UPD_high = 0x0400, //!< read update buffer registers
};

/*!
* Switch on/off safety word generation
*/
enum safetyTypes
{
SAFE_low = 0x0000, //!< switch of safety word generation
SAFE_high = 0x0001, //!< switch on safety word generation
};
uint8_t mMOSI; //!< Pin for SPI MOSI (pin 0.6 on test board);
uint8_t mMISO; //!< Pin for SPI MISO (pin 0.7 on test board)
uint8_t mSCK; //!< Pin for CLOCK (pin 0.8 on test board)
uint8_t mCS; //!< Pin for chip select (pin 0.9 on test board)

uint16_t data;
uint16_t _command1; //!< command write data [0] = command [1] = data to write
uint16_t _command2; //!< command write data [0] = command [1] = data to write
uint16_t _received[MAX_REGISTER_MEM]; //!< fetched data from sensor with last word = safety word
uint16_t _registers[CRC_NUM_REGISTERS]; //!< keeps track of the values stored in the 8 _registers, for which the CRC is calculated
int main(void)
{
/*****************************************************************************
** initialization of the hardware modules based on the configuration done **
** by using the IFXConfigWizard **
*****************************************************************************/
TLE_Init();
setup();


for (;;)
{
(void)WDT1_Service();
Delay_us(1000000);
enableSensor();
getAngleValue();
}
}

void setup()
{
mMOSI=0x02; //!< Pin for SPI MOSI (pin 0.6 on test board);
mMISO=0x24; //!< Pin for SPI MISO (pin 0.7 on test board)
mSCK=0x03; //!< Pin for CLOCK (pin 0.8 on test board)
mCS=0x01;
enableSensor();

}


enum errorTypes getAngleValue()
{
angleValue=0;
int16_t rawAnglevalue=0;
uint16_t rawData = 0;
enum errorTypes status = readFromSensor(REG_AVAL, &rawData);
if (status != NO_ERROR)
{
return (status);
}
rawData = (rawData & (DELETE_BIT_15));
//check if the value received is positive or negative
if (rawData & CHECK_BIT_14)
{
rawData = rawData - CHANGE_UINT_TO_INT_15;
}
rawAnglevalue = rawData;
angleValue = (ANGLE_360_VAL / POW_2_15) * ((double) rawAnglevalue);
return (status);
}
enum errorTypes readFromSensor(uint16_t command, uint16_t *data)
{
enum errorTypes checkError = NO_ERROR;

_command1 = READ_SENSOR | command | UPD_low | SAFE_low;
uint16_t _received[MAX_REGISTER_MEM] = {0};

//_spiConnection->setCSPin(mCS);
PORT_ChangePin(LED1, PORT_ACTION_SET);
//Delay_us(100);
//_spiConnection->sendReceiveSpi(_command1, 1, _received, 2);
PORT_ChangePin(LED1, PORT_ACTION_CLEAR);
SSC1_SendWord(_command1);
Delay_us(5000);

_received[0]=SSC1_ReadWord();

_received[1]=SSC1_ReadWord();
*data = _received[0];

PORT_ChangePin(LED1, PORT_ACTION_SET);
if (true)
{
// checkError = checkSafety(_received[1], _command1, &_received[0], 1);
if (checkError != NO_ERROR)
{
data = 0;
}
}

checkError=NO_ERROR;
return (checkError);
}
void enableSensor()
{

PORT_ChangePin(LED1, PORT_ACTION_SET);
//digitalWrite(mCS, HIGH);
}

void disableSensor()
{
PORT_ChangePin(LED1, PORT_ACTION_CLEAR);
//digitalWrite(mCS, low);
}
//-----------------------------------------------------------------------------
// none_class functions

/*!
* Gets the first byte of a 2 byte word
* @param twoByteWord insert word of two bytes long
* @return returns the first byte
*/
uint8_t getFirstByte(uint16_t twoByteWord)
{
return ((uint8_t) (twoByteWord >> 8));
}

/*!
* Gets the second byte of the 2 byte word
* @param twoByteWord insert word of two bytes long
* @return returns the second byte
*/
uint8_t getSecondByte(uint16_t twoByteWord)
{
return ((uint8_t) twoByteWord);
}

/*!
* Function for calculation the CRC.
* @param data byte long data for CRC check
* @param length length of data
* @return returns 8bit CRC
*/
uint8_t crc8(uint8_t *data, uint8_t length)
{
uint32_t crc;
int16_t i, bit;

crc = CRC_SEED;
for (i = 0; i < length; i++)
{
crc ^= data;
for (bit = 0; bit < 8; bit++)
{
if ((crc & 0x80) != 0)
{
crc <<= 1;
crc ^= CRC_POLYNOMIAL;
}else{
crc <<= 1;
}
}
}

return ((~crc) & CRC_SEED);
}

/*!
* Function for calculation of the CRC
* @param crcData byte long data for CRC check
* @param length length of data
* @return runs crc8 calculation and returns CRC
*/
uint8_t crcCalc(uint8_t* crcData, uint8_t length)
{
return (crc8(crcData, length));
}

/*!
* Calculate the angle speed
* @param angRange set angular range value
* @param rawAngleSpeed raw speed value from read function
* @param firMD
* @param predictionVal
* @return calculated angular speed
*/
double calculateAngleSpeed(double angRange, int16_t rawAngleSpeed, uint16_t firMD, uint16_t predictionVal)
{
double finalAngleSpeed;
double microsecToSec = 0.000001;
double firMDVal;
if (firMD == 1)
{
firMDVal = 42.7;
}else if (firMD == 0)
{
firMDVal = 21.3;
}else if (firMD == 2)
{
firMDVal = 85.3;
}else if (firMD == 3)
{
firMDVal = 170.6;
}else{
firMDVal = 0;
}
finalAngleSpeed = ((angRange / POW_2_15) * ((double) rawAngleSpeed)) / (((double) predictionVal) * firMDVal * microsecToSec);
return (finalAngleSpeed);
}

3991.attach

0 Likes
Fiz
Moderator
Moderator
Moderator
First like received 50 replies posted 25 replies posted
Hello Murat,

I am sorry for the long waiting time.
I am looking into the TLE5012b library and will let you know once I get it running.
What problems were you experiencing?
Best,
Fiz
0 Likes
User17857
Level 3
Level 3
First like received
Hello Fiz,

Welcome back:) I send 8021 to read angle value to the sensor and take back the same value which is 8021. SSC1 uses 40 mhz . can i reduce its frequency?
0 Likes
Fiz
Moderator
Moderator
Moderator
First like received 50 replies posted 25 replies posted
Hello Murat,

thank you! I looked at your code and made several changes: I used SSC2 instead of SSC1, this way I was able to use the debugger.
I
I also changed the sequence of the sent commands, this way I was able to see the correct commands. You can change the frequency for the SSC in
BaudRate Generation..
4145.attach

#include "tle_device.h"
#include "eval_board.h"

void setup();
double calculateAngleSpeed(double angRange, int16_t rawAngleSpeed, uint16_t firMD, uint16_t predictionVal);
uint8_t crcCalc(uint8_t* crcData, uint8_t length);
double angleValue;
uint8_t crc8(uint8_t *data, uint8_t length);
uint8_t getSecondByte(uint16_t twoByteWord);
uint8_t getFirstByte(uint16_t twoByteWord);
void enableSensor();
void disableSensor();
enum errorTypes getAngleValue();
enum errorTypes readFromSensor(uint16_t command, uint16_t *data);

/************************************************** ***************************/
/** SSC1: sends one byte (0xAA) as SPI master @ 1 Mbaud **/
/************************************************** ***************************/
/** program SSC1 to operate at 1 Mbaud **/
/** SSC1 sends one byte at P0.3 (CLK), P0.2 (MTSR) **/
/************************************************** ***************************/

#define TLE5012B_H

// Sensor registers
#define READ_SENSOR 0x8000 //!< base command for read
#define WRITE_SENSOR 0x5000 //!< base command for write
#define READ_BLOCK_CRC 0x8088 //!< initialize block CRC check command



#define SYSTEM_ERROR_MASK 0x4000 //!< System error masks for safety words
#define INTERFACE_ERROR_MASK 0x2000 //!< Interface error masks for safety words
#define INV_ANGLE_ERROR_MASK 0x1000 //!< Angle error masks for safety words

#define CRC_POLYNOMIAL 0x1D //!< values used for calculating the CRC
#define CRC_SEED 0xFF
#define CRC_NUM_REGISTERS 0x0008 //!< number of CRC relevant registers
#define MAX_REGISTER_MEM 0x0030 //!< max readable register values buffer

#define DELETE_BIT_15 0x7FFF //!< Value used to delete everything except the first 15 bits
#define CHANGE_UINT_TO_INT_15 0x8000 //!< Value used to change unsigned 16bit integer into signed
#define CHECK_BIT_14 0x4000 //!<
#define GET_BIT_14_4 0x7FF0 //!<

#define DELETE_7BITS 0x01FF //!< values used to calculate 9 bit signed integer sent by the sensor
#define CHANGE_UNIT_TO_INT_9 0x0200 //!< Value used to change unsigned 9bit integer into signed
#define CHECK_BIT_9 0x0100

#define POW_2_15 32768.0 //!< values used to for final calculations of angle speed, revolutions, range and value
#define POW_2_7 128.0 //!<
#define ANGLE_360_VAL 360.0

#define TEMP_OFFSET 152.0 //!< values used to calculate the temperature
#define TEMP_DIV 2.776

//!< Prints a binary number with leading zeros (Automatic Handling)
#define PRINTBIN(Num) for (uint32_t t = (1UL<< (sizeof(Num)*8)-1); t; t >>= 1) Serial.write(Num & t ? '1' : '0');
//!< Prints a binary number with leading zeros (Automatic Handling) with space
#define PRINTBINS(Num) for (uint32_t t = (1UL<< (sizeof(Num)*8)-1); t; t >>= 1) Serial.write(Num & t ? " 1 " : " 0 ");

/*!
* Error types from safety word
*/
enum errorTypes
{
NO_ERROR = 0x00, //!< NO_ERROR = Safety word was OK
SYSTEM_ERROR = 0x01, //!< SYSTEM_ERROR = over/under voltage, VDD negative, GND off, ROM defect
INTERFACE_ACCESS_ERROR = 0x02, //!< INTERFACE_ACCESS_ERROR = wrong address or wrong lock
INVALID_ANGLE_ERROR = 0x03, //!< INVALID_ANGLE_ERROR = NO_GMR_A = 1 or NO_GMR_XY = 1
ANGLE_SPEED_ERROR = 0x04, //!< ANGLE_SPEED_ERROR = combined error, angular speed calculation wrong
CRC_ERROR = 0xFF //!< CRC_ERROR = Cyclic Redundancy Check (CRC), which includes the STAT and RESP bits wrong
};

/*!
* Set the UPDate bit high (read from update buffer) or low (read directly)
*/
enum updTypes
{
UPD_low = 0x0000, //!< read normal registers
UPD_high = 0x0400, //!< read update buffer registers
};

/*!
* Switch on/off safety word generation
*/
enum safetyTypes
{
SAFE_low = 0x0000, //!< switch of safety word generation
SAFE_high = 0x0001, //!< switch on safety word generation
};
uint8_t mMOSI; //!< Pin for SPI MOSI (pin 0.6 on test board);
uint8_t mMISO; //!< Pin for SPI MISO (pin 0.7 on test board)
uint8_t mSCK; //!< Pin for CLOCK (pin 0.8 on test board)
uint8_t mCS; //!< Pin for chip select (pin 0.9 on test board)

uint16_t data;
uint16_t _command1; //!< command write data [0] = command [1] = data to write
uint16_t _command2; //!< command write data [0] = command [1] = data to write
uint16_t _received[MAX_REGISTER_MEM]; //!< fetched data from sensor with last word = safety word
uint16_t _registers[CRC_NUM_REGISTERS]; //!< keeps track of the values stored in the 8 _registers, for which the CRC is calculated
int main(void)
{
/************************************************** ***************************
** initialization of the hardware modules based on the configuration done **
** by using the IFXConfigWizard **
************************************************** ***************************/
TLE_Init();

disableSensor();
Delay_us(5000);
for (;;){
WDT1_Service();
getAngleValue();



}
}




enum errorTypes getAngleValue()
{
angleValue=0;
int16_t rawAnglevalue=0;
uint16_t rawData = 0;
enum errorTypes status = readFromSensor(0x0020, &rawData);
if (status != NO_ERROR)
{
return (status);
}
rawData = (rawData & (DELETE_BIT_15));
//check if the value received is positive or negative
if (rawData & CHECK_BIT_14)
{
rawData = rawData - CHANGE_UINT_TO_INT_15;
}
rawAnglevalue = rawData;
angleValue = (ANGLE_360_VAL / POW_2_15) * ((double) rawAnglevalue);
return (status);
}
enum errorTypes readFromSensor(uint16_t command, uint16_t *data)
{
enum errorTypes checkError = NO_ERROR;

_command1 = READ_SENSOR | command | UPD_low | SAFE_low;
uint16_t _received[MAX_REGISTER_MEM] = {0};

//Delay_us(100);
//_spiConnection->sendReceiveSpi(_command1, 1, _received, 2);
enableSensor();
Delay_us(1);
SSC2_SendWord(_command1);

Delay_us(20);
PORT_ChangePinAlt(0x11,0x0);
SSC2_SendWord(0x0000);
_received[0]=SSC2_ReadWord();
Delay_us(20);
SSC2_SendWord(0x0000);
_received[1]=SSC2_ReadWord();
Delay_us(20);
disableSensor();
PORT_ChangePinAlt(0x11,0x1);
Delay_us(100);


//_received[0]=SSC2_ReadWord();

//_received[1]=SSC2_ReadWord();
//*data = _received[0];
Delay_us(1000);
if (true)
{
// checkError = checkSafety(_received[1], _command1, &_received[0], 1);
if (checkError != NO_ERROR)
{
data = 0;
}
}

checkError=NO_ERROR;
return (checkError);
}
void enableSensor()
{

PORT_P04_Output_Low_Set();
}

void disableSensor()
{
PORT_P04_Output_High_Set();
//digitalWrite(mCS, low);
}
//-----------------------------------------------------------------------------
// none_class functions

/*!
* Gets the first byte of a 2 byte word
* @param twoByteWord insert word of two bytes long
* @return returns the first byte
*/
uint8_t getFirstByte(uint16_t twoByteWord)
{
return ((uint8_t) (twoByteWord >> 8));
}

/*!
* Gets the second byte of the 2 byte word
* @param twoByteWord insert word of two bytes long
* @return returns the second byte
*/
uint8_t getSecondByte(uint16_t twoByteWord)
{
return ((uint8_t) twoByteWord);
}

/*!
* Function for calculation the CRC.
* @param data byte long data for CRC check
* @param length length of data
* @return returns 8bit CRC
*/
uint8_t crc8(uint8_t *data, uint8_t length)
{
uint32_t crc;
int16_t i, bit;

crc = CRC_SEED;
for (i = 0; i < length; i++)
{
crc ^= data;
for (bit = 0; bit < 8; bit++)
{
if ((crc & 0x80) != 0)
{
crc <<= 1;
crc ^= CRC_POLYNOMIAL;
}else{
crc <<= 1;
}
}
}

return ((~crc) & CRC_SEED);
}

/*!
* Function for calculation of the CRC
* @param crcData byte long data for CRC check
* @param length length of data
* @return runs crc8 calculation and returns CRC
*/
uint8_t crcCalc(uint8_t* crcData, uint8_t length)
{
return (crc8(crcData, length));
}

/*!
* Calculate the angle speed
* @param angRange set angular range value
* @param rawAngleSpeed raw speed value from read function
* @param firMD
* @param predictionVal
* @return calculated angular speed
*/
double calculateAngleSpeed(double angRange, int16_t rawAngleSpeed, uint16_t firMD, uint16_t predictionVal)
{
double finalAngleSpeed;
double microsecToSec = 0.000001;
double firMDVal;
if (firMD == 1)
{
firMDVal = 42.7;
}else if (firMD == 0)
{
firMDVal = 21.3;
}else if (firMD == 2)
{
firMDVal = 85.3;
}else if (firMD == 3)
{
firMDVal = 170.6;
}else{
firMDVal = 0;
}
finalAngleSpeed = ((angRange / POW_2_15) * ((double) rawAngleSpeed)) / (((double) predictionVal) * firMDVal * microsecToSec);
return (finalAngleSpeed);
}



//ISRS//

void end_of_transmition(void){
//disableSensor();
//SSC2_RX_Int_Clr();
}
0 Likes
Fiz
Moderator
Moderator
Moderator
First like received 50 replies posted 25 replies posted
I also attached a picture of my SPI frame
4146.attach
0 Likes
YanU
Level 1
Level 1
First like received First reply posted First question asked

Dear all,

revisiting this topic since during bringup of TLE5012b positions sensor with our TLE987x board (which is almost indentical to eval. kit HW) we came across the same issues. Independently from this topic we implemented the same method to send the 16bit command and then send additional 2x16 clock pulses in order to retrieve sensor data to SSC2. Initially we did not have the MTSR port direction switching in order to put the line to HiZ, but we added that as well based on your code above. We can clearly see the sensor response on MRST pin (P1.2) on oscilloscope, however the receive buffer is always 0x0000.
I'm curious to hear if anyone has successfully moved forward with this topic since I have no idea why the received data is not copied into receive buffer of SSC2.

Thanks, Best Regards, Jan.

AmolKoli
Level 4
Level 4
First solution authored 10 questions asked 50 sign-ins

I am using MOTORCONTROLKIT, which has TLE5012b integrated.
I was able to set up and read the sensor values via SSC1 and SSC2 as well.
I just used a code from the community and modified it a little. 
I hope you were able to do it too.

See if this part for config helps:
void configSensor(void)
{
//Enable prediction, disable autocal
PORT_P00_Output_Low_Set();
SSC2_SendWord(0x5080);
SSC2_SendWord(0x0804);
PORT_P00_Output_High_Set();
for(int i=0;i<1000;i++);

//Read 0x0D (for IIF-Hysteresis option)
PORT_P00_Output_Low_Set();
SSC2_SendWord(0x80D0);
//PORT_P02_OpenDrain_En();
uint16_t reg = SSC2_SendWord(0xFFFF);
//PORT_P02_OpenDrain_Dis();
PORT_P00_Output_High_Set();
for(int i=0;i<1000;i++);
//Write Hysteresis option in 0x0D to 0x00 (0ー)
reg &= 0xFFFC;
PORT_P00_Output_Low_Set();
SSC2_SendWord(0x50D0);
SSC2_SendWord(reg);
PORT_P00_Output_High_Set();
for(int i=0;i<1000;i++);

//Enable prediction, enable autocal
PORT_P00_Output_Low_Set();
SSC2_SendWord(0x5080);
SSC2_SendWord(0x0805);
PORT_P00_Output_High_Set();
for(int i=0;i<1000;i++);

//read STAT to clear S_FUSE
PORT_P00_Output_Low_Set();
SSC2_SendWord(0x8000);
//PORT_P02_OpenDrain_En();
SSC2_SendWord(0xFFFF);
//PORT_P02_OpenDrain_Dis();
PORT_P00_Output_High_Set();
}

0 Likes