MCP4131 with 8 - bit

I am using MCP4131 with 7 - bit ( 0 - 127 ). Datasheet said that, it can work bit 7 and 8 bit and i definetly need to use it with 8 bit ( 0 - 255 ). Here is my code below;

#include <SPI.h>
int CS= 10;
void setup()
{
pinMode (CS, OUTPUT);
SPI.begin();

}
void loop()
{
digitalPotWrite(50);
}

int digitalPotWrite(int value)
{
digitalWrite(CS, LOW);
SPI.transfer(value);
digitalWrite(CS, HIGH);
}


This is 7 bit code, to make it 8 bit, What should i change in the code ? Or what i need to do ?

Thank You Best Regards

• What does the datasheet tell you about its protocol, specifically? – Wossname Dec 9 '16 at 13:01
• <pedantic>7-bit is 0-127 and 8-bit is 0-255</pedantic> – Roger Rowland Dec 9 '16 at 13:02
• @Wossname SPI Communication – Firat Dagkiran Dec 9 '16 at 13:05
• @RogerRowland, this specific device actually does have 257 steps in it's 8bit mode. 0-255 and MAX. Weird. It's because there are 256 resistors internally, which gives 256+1 taps including both ends. I've used this chip before and it's pretty awesome actually. – Wossname Dec 9 '16 at 13:06
• @FiratDagkiran, you need to read the datasheet in detail. You need to research the problem before anyone will help you. – Wossname Dec 9 '16 at 13:08

This depends a lot on what is written in the datasheet on how to use it with the 8-bit feature. However, from your code it looks like you are storing the value in an integer and then writing that. Changing from int to unsigned int should work in this scenario but still a lot depends on what is written in the datasheet. It would be better if you clearly specify what is written in the datasheet regarding the use of 8-bit and 7-bit feature.