TLC549 pin connections

Interface Example PIC16F628 Reading TLC548 Serial ADC

by Lewis Loflin

  
  

The following program will read the 8-bit value from a TLC548 ADC and display the binary values on eight LEDs connected to PORTB. This page discusses parts of the programming. Note that many of these programs work on a PIC16F84A unless one needs comparators or pulse-width-modulation.

See the complete program: TLC548_binary.asm

;--------------------------------------
DATABIT  equ 0  ; DATA bit TLC548 pin 6 to RA0
CLK		 equ 1  ; CLK TLC548 pin 7 to RA1
CS 		 equ 2  ; select TLC548 pin 5 to RA2
;---------------------------------------

Above is the pin connections to the TLC548 serial analog-to-digital converter. This has three control pins labeled CS, Data Out, IO clock. They are connected RA0, RA1, and RA2 as shown above.

read_adc ; value returned in val

	clrf val
	bcf PORTA, CS ; LOW CS
	movlw 0x08
	movwf i
zz	bsf PORTA, CLK  ; HIGH CLK
	call delay_1ms
	btfss PORTA, DATABIT
	goto $+3  
   	movlw 0x01
	addwf val, F 
	bcf PORTA, CLK  ; LOW CLK
	decfsz i, F
	goto $+3
	goto $+4
	nop
	rlf val
	goto zz
 	bsf PORTA, CS  ; HIGH CS
	return

Above is the assembly language ADC subroutine. It uses a temp variable i is a counter index and returns the 8-bit value in val. It works as follows:

i = 8;
CS is taken LOW to select device;
CLK is taken HIGH - a LOW to HIGH transition shift out 1st MSB;
delay 1mSec ;
DATABIT either a HIGH or LOW is added to val
CLK goes LOW;
val is shifted left one position;
i is decremented by 1;
process repeats 8 times and exits when i = 0;
CS is set HIGH.

main
	call read_adc 
	; value returned in val
	movf val, w
	movwf PORTB ; display val at PORTB LEDs
	call delay_100ms
goto main

Main program loop.

See tlc548.pdf

See How I got into Electronics


Loading


Pin connections PIC 16F628.

 


donate