Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LTC1298 and Bascom 8051

Status
Not open for further replies.

frigo

Junior Member level 3
Joined
Jul 11, 2001
Messages
29
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
ITALY
Activity points
255
ltc1298

Hi all,
Can anyone help me sort out the use of channel 0 and 1 thanks.
In the example of LTC1298 AD Convert by MCS does any one know how to switch channels from 0 to 1.
The example works fine but uses only channel 1 & not being very good with ass & code etc atm I do not know how to control the channels independently yet.
If any one could show some code or shed some light on this subject it would be great.
The LTC1298 example by MCS can be found in the MCS example folder.
I need info for bascom 8051 NOT for AVR!.
Tankyou
Frigo
 

anclk

First you have to send 4-bit word to the LTC1298 (1101 to select CH0 and 1111 to select CH1) then you can read the 12-bit contents of CH0 (or CH1).
Here is an example ASM code (with comments) that shows how to select CH0 or CH1 ..
CH0 output = AIN1H..AIN1L
CH1 output = AIN2H..AIN2L

Code:
; ====================================================
; 12b A/D converter subs...
;ANCLK	 = P1.0
;ANDATA   = P1.1
;AINCS	 = P1.2
;AIN1L			DATA	30h
;AIN1H			DATA	31h
;AIN2L			DATA	32h
;AIN2H			DATA	33h

Read_AnalogInputs:

Ch0_Read:
	   MOV	A, #0D0h		; 1101..CH0..
		SETB	AINCS		; CS must be H..

		MOV	B, #0Fh      ; Time delay..
		DJNZ	B, $

		CLR	AINCS		; CS goes L..

		MOV	R4, #04h		; Load counter..send command to A/D
Loop_Ch0_1:	RLC	A		; Rotate Dbit into Carry..
		CLR	ANCLK		; CLK goes L..
		MOV	ANDATA, C	; Output Din/out..
		SETB	ANCLK		; CLK goes H..
		DJNZ	R4, Loop_Ch0_1

		SETB	ANDATA		; D becomes an input..
		CLR	ANCLK		; CLK goes L..
		MOV	R4, #05h		; Read 1dummy+4bits from A/D

Loop_Ch0_2:	MOV	C, ANDATA	; Read data bit into Carry..
		RLC	A		; Rotate data in ACC..
		SETB	ANCLK		; CLK goes H..
		CLR	ANCLK		; CLK goes L..
		DJNZ	R4, Loop_Ch0_2
		ANL	A, #0Fh
		MOV	AIN1H, A

		MOV	R4, #08h		; read remaining 8 bits from A/D..
Loop_Ch0_3:	MOV	C, ANDATA
		RLC	A
		SETB	ANCLK
		CLR	ANCLK
		DJNZ	R4, Loop_Ch0_3
		MOV	AIN1L, A

		SETB	AINCS



Ch1_Read:
	MOV	A, #0F0h		; 1111..Ch1..
		SETB	AINCS		; CS must be H..

		MOV	B, #0Fh
		DJNZ	B, $

		CLR	AINCS		; CS goes L..

		MOV	R4, #04h		; Load counter..send command to A/D
Loop_Ch1_1:	RLC	A		; Rotate Dbit into Carry..
		CLR	ANCLK		; CLK goes L..
		MOV	ANDATA, C	; Output Din/out..
		SETB	ANCLK		; CLK goes H..
		DJNZ	R4, Loop_Ch1_1

		SETB	ANDATA		; D becomes an input..
		CLR	ANCLK			; CLK goes L..
		MOV	R4, #05h		; Read 1dummy+4bits from A/D

Loop_Ch1_2:	MOV	C, ANDATA	; Read data bit into Carry..
		RLC	A		; Rotate data in ACC..
		SETB	ANCLK		; CLK goes H..
		CLR	ANCLK		; CLK goes L..
		DJNZ	R4, Loop_Ch1_2
		ANL	A, #0Fh
		MOV	AIN2H, A

		MOV	R4, #08h		; read remaining 8 bits from A/D..
Loop_Ch1_3:	MOV	C, ANDATA
		RLC	A
		SETB	ANCLK
		CLR	ANCLK
		DJNZ	R4, Loop_Ch1_3
		MOV	AIN2L, A

		SETB	AINCS

		RET

; ====================================================

Try to "insert" this code into BASCOM ..

Rgds,
IanP
 

r4 bascom

Tank you IamP
Very good description
Frigo
 

I'm also working with this ADC and 89c52 microcontroller.Could u pls provide me the program for BASCOM-8051 in Basic Language. That will be very nice of u.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top