Thanks Steve!
I appreciate that you took the time to give me the reference. Very helpful.
Bo
Thanks Steve!
I appreciate that you took the time to give me the reference. Very helpful.
Bo
Interesting, that explanation doesn't show up in either the MCP4821 or MCP4921 datasheets.
Thanks again for the heads up
Bo
After studying this for a few nights, the fog is beginning to clear a bit, but not completely.
On the above mentioned inclinometer (sca61t, pages 11 &12), you send a command and then concurrently it sends back a reply with the data. I think I can see how to send the command, and extend the transmission to 19 clocks so that it can fit in the response by leaving CS low with the [var\19] in SEROUT. What I don't see how to grab those reply bits using SEROUT and SERIN. Each one would execute in order and not catch the response as both share the clock.
Will test further, but I suspect that I might have to resort to the hardware SPI.Code:I VAR WORD D VAR WORD CS_I VAR PORTC.2 ' chip select Inclinomteter CS_D VAR PORTC.3 ' chip select D/A SCK VAR PORTC.5 ' clock SDI VAR PORTC.4 ' data OUT SDO VAR PORTC.7 ' data IN IncIn var word HIGH CS_I HIGH CS_D LOW SCK I = %0001000000000000 'send RDAX & fill to get 11 bits of data D = %0001111111111111 '2x, active, max output for test '*** Inclinometer Commands *********** 'MEAS 00000000 'Measure (Exit self test) 'RWTR 00001000 'R/W Temp 'RDSR 00001010 'Read Status register 'RLOAD 00001011 'relaod NV to o/p 'STX 00001110 'activate self test 'RDAX 00010000 'read acceleration Main: GOSUB IncRdg GOSUB DACout goto main '**** Subs ********************************* ;---- Sub to read the inclinometer ------------------ IncRdg: LOW CS_i ' enable writes to Inclinometer SHIFTOUT SDI,SCK,0,[I\19] 'sends command to READ ' SHIFTIN SDO,SDK,0,[IncIn\11] ' I don't see this working HIGH CS_I PAUSE 5 RETURN ''---- Sub to output to the D/A converter ----- 'DACout: ' LOW CS_D ' enable writes to D/A converter ' SHIFTOUT SDI,SCK,0,[D\16] ' HIGH CS_D ' PAUSE 5 ' return
Any thoughts?
Bo
Hi,
I just took a quick look at this but as far as I can see the commands are 8 bits and the response from the device is 11 bits starting at the 9th clock pulse. So, if reading the acceleration you first SHIFTOUT the 8 bit RDAX command, then you SHIFTIN 11 bits for a total of 19bits.
After banging around for a while, I was able to get this to give me good data from the inclinometer:
My LOGIC pod had a bit of a rough time trying to make sense of the unusual length of data and that threw me for a bit, but the HSEROUT showed that all was good. .Code:CS_I VAR PORTD.0 ' chip select Inclinomteter CS_D VAR PORTC.3 ' chip select D/A SCK VAR PORTD.3 ' clock SDI VAR PORTD.2 ' data IN , MISO SDO VAR PORTD.1 ' data OUT, MOSI IncIn var word HIGH CS_I HIGH CS_D LOW SCK HIGH CS_I 'I = %00001000 'send TeMP command I = %00010000 'send RDAX Main: GOSUB iNCrDG hserout ["IncRdg ",bin IncIn," ",DEC IncIn," ",10,13] PAUSE 100 goto main '**** Subs ********************************* ;---- Sub to read the inclinometer ------------------ IncRdg: LOW CS_I ' enable writes to Inclinometer SHIFTOUT SDO,SCK,1,[I] 'sends command to READ SHIFTIN SDI,SCK,0,[IncIn\11] HIGH CS_I RETURN
Hope that help someone.
Bo
Bookmarks