|
|
View previous topic :: View next topic |
Author |
Message |
dave.t Guest
|
microchip potentiometers mcp41050 |
Posted: Tue Feb 04, 2003 11:29 am |
|
|
Hi all
I am trying to write to a mcp41050 digital potentiometer and am using the function below.I am using a 16f877 @ 4mhz ,I have tested the clock,serial_out and chip_select lines from the controller and these are ok.I have been going over it and cannot find anything wrong maybe another set of eyes would help!
On power up of my controller the pot does reset itself at mid scale.
Many thanks for any help!!!
Dave
void digi_pot(char data);
void digi_pot()
{
char count,command,pot_data;
pot_data=data;
command=digi_command; // 0x11
#asm
bcf clock // make sure clock is low
movlw 0x08 // load
movwf count // first 8 bit count
bcf chip_select // select chip
cmlp:rlf command,f // move command out to carry msb first
btfsc carry
bsf serial_out // data out high
nop // allow data
nop // to settle
bsf clock // clock high
nop // wait
nop // wait
bcf clock // clock low
nop
decfsz count,f // all bits clocked out?
goto cmlp
// yes!
movlw 0x08 // load
movwf count // second 8 bit count
dblp:rlf pot_data,f // pot value
btfsc carry
bsf serial_out // data output high
nop // allow data
nop // to settle
bsf clock // clock high
nop // wait
nop // wait
bcf clock // clock low
nop
decfsz count,f // all bits clocked out?
goto dblp
bsf chip_select // yes! all sixteen bits clocked out
// chip select is now taken high to latch data and update pot!
#endasm
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 11271 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: microchip potentiometers mcp41050 |
Posted: Tue Feb 04, 2003 1:50 pm |
|
|
<font face="Courier New" size=-1>:=Hi all
:=
:=I am trying to write to a mcp41050 digital potentiometer and am using the function below.I am using a 16f877 @ 4mhz ,I have tested the clock,serial_out and chip_select lines from the controller and these are ok.I have been going over it and cannot find anything wrong maybe another set of eyes would help!
:=On power up of my controller the pot does reset itself at mid scale.
----------------------------------------------------------
Since this is a C board, possibly you should write it in C. :)
I did a little bit of web searching, and found some sample code
for a mcp41xxx. It's written in CCS C. See the link below.
Note that in his comments, he refers to possible problems
with SPI and CCS. If you have problems, you should review
the recent posts that Charlie U has made regarding CCS and SPI.
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11276 |
|
|
Steve H Guest
|
Check this driver out.... |
Posted: Tue Feb 04, 2003 2:20 pm |
|
|
Here is a link to a driver that I did for a dual Microchip Digipot. I don't use the SPI functions (perhaps I'm dumb) because the devices that I usually end up with require an odd number of bits so I'm in the habit of just stuffing the bits myself (I also think it is easier for me to catch my errors this way).
Regards,
Steve H.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11277 |
|
|
Bruce R. Knox Guest
|
Re: microchip potentiometers mcp41050 |
Posted: Tue Feb 04, 2003 7:23 pm |
|
|
:=Hi all
:=
:=I am trying to write to a mcp41050 digital potentiometer and am using the function below.I am using a 16f877 @ 4mhz ,I have tested the clock,serial_out and chip_select lines from the controller and these are ok.I have been going over it and cannot find anything wrong maybe another set of eyes would help!
:=On power up of my controller the pot does reset itself at mid scale.
:=Many thanks for any help!!!
:=
:=Dave
:=
:=void digi_pot(char data);
:=
:=void digi_pot()
:=
:={
:=
:=char count,command,pot_data;
:=
:=pot_data=data;
:=command=digi_command; // 0x11
:=
:=#asm
:= bcf clock // make sure clock is low
:= movlw 0x08 // load
:= movwf count // first 8 bit count
:= bcf chip_select // select chip
:=
:= cmlp:rlf command,f // move command out to carry msb first
:= btfsc carry
:= bsf serial_out // data out high
:= nop // allow data
:= nop // to settle
:= bsf clock // clock high
:= nop // wait
:= nop // wait
:= bcf clock // clock low
:= nop
:= decfsz count,f // all bits clocked out?
:= goto cmlp
:= // yes!
:= movlw 0x08 // load
:= movwf count // second 8 bit count
:=
:= dblp:rlf pot_data,f // pot value
:= btfsc carry
:= bsf serial_out // data output high
:= nop // allow data
:= nop // to settle
:= bsf clock // clock high
:= nop // wait
:= nop // wait
:= bcf clock // clock low
:= nop
:= decfsz count,f // all bits clocked out?
:= goto dblp
:= bsf chip_select // yes! all sixteen bits clocked out
:= // chip select is now taken high to latch data and update pot!
:=#endasm
:=
:=}
Dave:
Put a "bcf serial_out" at the beginning of each loop (just before the shift) - you're never clearing the data bit, only setting it. That should make it work, I think.
Bruce
___________________________
This message was ported from CCS's old forum
Original Post ID: 11283 |
|
|
dave.t Guest
|
Re: microchip potentiometers mcp41050 |
Posted: Wed Feb 05, 2003 3:10 am |
|
|
:=:=Hi all
:=:=
:=:=I am trying to write to a mcp41050 digital potentiometer and am using the function below.I am using a 16f877 @ 4mhz ,I have tested the clock,serial_out and chip_select lines from the controller and these are ok.I have been going over it and cannot find anything wrong maybe another set of eyes would help!
:=:=On power up of my controller the pot does reset itself at mid scale.
:=:=Many thanks for any help!!!
:=:=
:=:=Dave
:=:=
:=:=void digi_pot(char data);
:=:=
:=:=void digi_pot()
:=:=
:=:={
:=:=
:=:=char count,command,pot_data;
:=:=
:=:=pot_data=data;
:=:=command=digi_command; // 0x11
:=:=
:=:=#asm
:=:= bcf clock // make sure clock is low
:=:= movlw 0x08 // load
:=:= movwf count // first 8 bit count
:=:= bcf chip_select // select chip
:=:=
:=:= cmlp:rlf command,f // move command out to carry msb first
:=:= btfsc carry
:=:= bsf serial_out // data out high
:=:= nop // allow data
:=:= nop // to settle
:=:= bsf clock // clock high
:=:= nop // wait
:=:= nop // wait
:=:= bcf clock // clock low
:=:= nop
:=:= decfsz count,f // all bits clocked out?
:=:= goto cmlp
:=:= // yes!
:=:= movlw 0x08 // load
:=:= movwf count // second 8 bit count
:=:=
:=:= dblp:rlf pot_data,f // pot value
:=:= btfsc carry
:=:= bsf serial_out // data output high
:=:= nop // allow data
:=:= nop // to settle
:=:= bsf clock // clock high
:=:= nop // wait
:=:= nop // wait
:=:= bcf clock // clock low
:=:= nop
:=:= decfsz count,f // all bits clocked out?
:=:= goto dblp
:=:= bsf chip_select // yes! all sixteen bits clocked out
:=:= // chip select is now taken high to latch data and update pot!
:=:=#endasm
:=:=
:=:=}
:=
:=Dave:
:=
:=Put a "bcf serial_out" at the beginning of each loop (just before the shift) - you're never clearing the data bit, only setting it. That should make it work, I think.
:=
:=Bruce
___________________________
This message was ported from CCS's old forum
Original Post ID: 11290 |
|
|
dave.t Guest
|
Re: microchip potentiometers - Thanks Bruce it worked! Thank |
Posted: Wed Feb 05, 2003 3:12 am |
|
|
:=:=Hi all
:=:=
:=:=I am trying to write to a mcp41050 digital potentiometer and am using the function below.I am using a 16f877 @ 4mhz ,I have tested the clock,serial_out and chip_select lines from the controller and these are ok.I have been going over it and cannot find anything wrong maybe another set of eyes would help!
:=:=On power up of my controller the pot does reset itself at mid scale.
:=:=Many thanks for any help!!!
:=:=
:=:=Dave
:=:=
:=:=void digi_pot(char data);
:=:=
:=:=void digi_pot()
:=:=
:=:={
:=:=
:=:=char count,command,pot_data;
:=:=
:=:=pot_data=data;
:=:=command=digi_command; // 0x11
:=:=
:=:=#asm
:=:= bcf clock // make sure clock is low
:=:= movlw 0x08 // load
:=:= movwf count // first 8 bit count
:=:= bcf chip_select // select chip
:=:=
:=:= cmlp:rlf command,f // move command out to carry msb first
:=:= btfsc carry
:=:= bsf serial_out // data out high
:=:= nop // allow data
:=:= nop // to settle
:=:= bsf clock // clock high
:=:= nop // wait
:=:= nop // wait
:=:= bcf clock // clock low
:=:= nop
:=:= decfsz count,f // all bits clocked out?
:=:= goto cmlp
:=:= // yes!
:=:= movlw 0x08 // load
:=:= movwf count // second 8 bit count
:=:=
:=:= dblp:rlf pot_data,f // pot value
:=:= btfsc carry
:=:= bsf serial_out // data output high
:=:= nop // allow data
:=:= nop // to settle
:=:= bsf clock // clock high
:=:= nop // wait
:=:= nop // wait
:=:= bcf clock // clock low
:=:= nop
:=:= decfsz count,f // all bits clocked out?
:=:= goto dblp
:=:= bsf chip_select // yes! all sixteen bits clocked out
:=:= // chip select is now taken high to latch data and update pot!
:=:=#endasm
:=:=
:=:=}
:=
:=Dave:
:=
:=Put a "bcf serial_out" at the beginning of each loop (just before the shift) - you're never clearing the data bit, only setting it. That should make it work, I think.
:=
:=Bruce
___________________________
This message was ported from CCS's old forum
Original Post ID: 11291 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|