PDA

View Full Version : LTC 1418 14bit ADC- Serial mode



paul.mcallister
- 29th October 2006, 20:51
Hi,

I am experimenting with an LTC1418, 14 bit ADC in serial mode connected to a PIC16F876a.

I think I have it configured correctly but I might have a problem with the serial interface code.

Has anyone ever used this device, and if so could you share with me some code examples.

Thanks, Paul

mister_e
- 30th October 2006, 03:31
How about sending your code here so we may find some mistake?

paul.mcallister
- 8th November 2006, 02:50
Hi all,

I ultimately got this device to work, the problem was mostly hardware configuration. For any one who needs to do this in the future here is some stub code to get you started:


' Stub code for testing LTC 1418 ADC in serial mode
' Target processor - 16F876A
'
' 1418 configuration
' - CS = gnd
' - Ext/Int = gnd
' - Ser/Par = hi
' - shdn = hi
' - Vss = gnd
' - A- = gnd
' Seems to convert faster that the busy flag can be read at 4 mhz
'
'
'

'----- Include Files -----------------------------------------------------------

Define LOADER_USED 1

INCLUDE "modedefs.bas"

'----- I/O pins ----------------------------------------------------------------

'Port B0 to B3 = Input pins, B4 to B7 = Output
pinADCSerialOut var PORTB.0 ' ADC converter out, pin 19
'pinAdcbusy VAR PORTB.1 ' ADC Busy flag, pin 26
' VAR PORTB.2 ' Unused
' VAR PORTB.3 ' Unused
' VAR PortB.4 ' Unused
' VAR PortB.5 ' Unused
' Var PortB.6 ' Unused
' VAR PortB.7 ' Unused


'Port C0 to C6 = Output pins
pinAdcCLK var PORTC.0 ' SLCL, pin 17
pinAdcRD var PORTC.1 ' RD, pin 23
pinConvStart var PORTC.2 ' CONVST, pin 24
' var PORTC.3 ' Unused
' var PORTC.4 ' Unused
' var PORTC.5 ' Unused
' PortC.6 ' serial out
' PortC.7 ' serial in

' 0 = output, 1 = input
ioPortB con %00000111' Set Port B.0 ~ B.2 to inputs, B3 ~ B.7 to output
ioPortC con %10000000' Set Port C.0 ~ C.6 to outputs, C.7 as input

'----- DEBUG Port Definitions --------------------------------------------------

DEFINE DEBUG_REG PORTC
DEFINE DEBUG_BIT 6 'Debug serial output, PORTC.6 set to an output
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 0
DEFINE DEBUGIN_REG PORTC
DEFINE DEBUGIN_BIT 7 'Debug serial input, PORTC.7 set to an input
DEFINE DEBUGIN_MODE 0
DEFINE DEBUG_PACING 500
DEFINE CHAR_PACING 500

'----- General variables -------------------------------------------------------

AdcVal var word ' 14 bit value from the ADC

' *-----------------------------------------------------------------------------

high pinAdcRD

loop:

readADC:
' ** get one ADC reading


low pinConvStart ' pinConvStart = C.2, connected to pin 24, CONVST
pauseUS 100
high pinConvStart
pauseUS 100 ' Wait, instead of reading the busy flag

low pinAdcRD ' pinAdcRD = C.1, connected to pin 23, READ

SHIFTIN pinADCSerialOut, pinAdcCLK, MSBPRE, [AdcVal\14]
' pinADCSerialOut = B.0, connected to pin 19, Dout
' pinAdcCLK = C.0, connected to pin 17, SCLK
high pinAdcRD


debug "AdcVal ", sbin AdcVal
debug " ", sdec AdcVal
debug CR

pause 500
goto loop

' End of program-----------------------------------------

mister_e
- 8th November 2006, 03:33
you miswired the EXT/INT pin. It have to be tied to VCC.

Also, you should use HSERIN instead of DEBUG. Your PIC have a USART... use it.

paul.mcallister
- 8th November 2006, 12:36
Steve,

Thanks for the tip on HSERIN, I haven't used them in serial mode much, hence not given it much thought.

Yes your correct, Ext/Int needs to be tied low. I checked my breadboard and that is what I had done, however my documentation in the code is incorrect.
I'll fix that, otherwie I'll look at it in 6 months time, get it wrong and wonder why.

Paul