Hi.
I cannot write a new value to a mcp41010 SPI Digital Potentiometer. What I'm trying to do is
UpdPotVal goes from 0 to 255Code:WriteSPI: CS = 0 ' Enable serial EEPROM Shiftout SI, SCK, MSBFIRST, [$06] ' Send write enable command CS = 1 ' Disable to execute command CS = 0 ' Enable Shiftout SI, SCK, MSBFIRST, [$02, 0, 0, UpdPotVal] ' Send address and data CS = 1 ' Disable RETURN
Can somebody please tell me what I am doing wrong. Here is a C code that does the same thing in case somebody knows how to make use of it!
RegardsCode:#define CS PIN_B4 #define SCLK PIN_B2 #define SI PIN_B1 set_pot (int data) { BYTE i; BYTE cmd[2]; cmd[0] = data; cmd[1] = 0x11; output_low(SCLK); output_low(CS); for(i=1;i<=16;++i) { output_bit(SI, shift_left(cmd,2,0)); output_high(SCLK); output_low(SCLK); } output_high(CS); } shutdown_pot () { BYTE i; BYTE cmd[2]; cmd[0] = 0; cmd[1] = 0x21; output_low(SCLK); output_low(CS); for(i=1;i<=16;++i) { output_bit(SI, shift_left(cmd,2,0)); output_high(SCLK); output_low(SCLK); } output_high(CS); }





Bookmarks