AS1116 - 7 Segment Display Driver - SOLVED

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello fellow freaks

I'm trying to use an AS1116-BST 7 Segment Display driver with 0 percent luck so far.

I'm wondering if anyone else has used one before. I think I'm sending the correct initialisation characters. I've verified with a storage CRO that the SPI transfer is sending what I think I should be sending etc. I get nothing at all on my display. I've check the SPI speed is well above the minimum transfer times.

Here is my test code. Schematic attached too.

.equ	DIGPOS_0	=	$01
.equ	DIGPOS_1	=	$02
.equ	DIGPOS_2	=	$03
.equ	DIGPOS_3	=	$04
.equ	DIGPOS_4	=	$05
.equ	DIGPOS_5	=	$06
.equ	DIGPOS_6	=	$07
.equ	DIGPOS_7	 =	$08

.equ	DECODE_MODE			=	$09
.equ	GLOBAL_INTENSITY	=	$0A
.equ	SCAN_LIMIT			=	$0B
.equ	SHUT_DOWN			=	$0C
.equ	FEATURE				=	$0E
.equ	DISPLAY_TEST_MODE	=	$0F

;************************************************

INIT_DISPLAY:						; initialise the display and turn on

	sbi		PORTB,		FSK_SS		; disable FSK
	cbi		PORTB,		DISP_SS		; enable display

	rcall	WAIT

	ldi		SPI_DATA,	$01			; load normal operation reset to default settings command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	SHUT_DOWN	; load shut down register
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$42			; load enable command ( 0100 0010 )
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	FEATURE		; load feature register
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$FF			; load decode command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	DECODE_MODE	; load decode register
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$07			; load enable command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	GLOBAL_INTENSITY	; load global intensity register
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$07			; load enable command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	SCAN_LIMIT	; load scan limit register
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$FF			; load full intensity command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	$10			; load  intensity register
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	sbi		PORTB,		DISP_SS		; disable display

	ret

;****************************

TEST_DISPLAY:						; turn on all display segments

	sbi		PORTB,		FSK_SS		; disable FSK
	cbi		PORTB,		DISP_SS		; enable display

	rcall	WAIT
	rcall	WAIT

	ldi		SPI_DATA,	$00			; load enable command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	DIGPOS_0	; load position
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$01			; load enable command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	DIGPOS_1	; load position
	rcall	SPI_TRANSFER			; send command
	
	rcall	WAIT

	ldi		SPI_DATA,	$02			; load enable command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	DIGPOS_2	; load position
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$03			; load enable command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	DIGPOS_3	; load position
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$04			; load enable command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	DIGPOS_4	; load position
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$05			; load enable command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	DIGPOS_5	; load position
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$06			; load enable command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	DIGPOS_6	; load position
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	ldi		SPI_DATA,	$07			; load enable command
	rcall	SPI_TRANSFER			; send command
	ldi		SPI_DATA,	DIGPOS_7	; load position
	rcall	SPI_TRANSFER			; send command

	rcall	WAIT

	sbi		PORTB,		DISP_SS		; disable display

	ret

;************************************

Attachment(s): 

Last Edited: Sun. Oct 28, 2012 - 04:09 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The code for SPI_TRANSFER and WAIT is not shown.

To set a register LD (load) must taken and held Low while all 16 bits (data + address) are sent/clocked and then High.
To read a register LD (load) must taken and held Low while 8 bits (address) are sent/clocked and then High with 8 bits of data being read/clocked out.

Stan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry I didn't post them. Those bits are working, but I understand your desire to see them.

I do take the LD pin low for the whole transmission and then take it high at the end. Ahhh you now make me wonder whether I have to take it high after each 16 bit write rather than leave it low for the whole 5-10 bytes that I send... Will try that now!

;*******************************************************************************
;Send data in SPI_DATA out the SPI. Data received is returned to SPI_DATA

SPI_TRANSFER:

	push	TEMP

	out	SPDR0,	SPI_DATA		; Start transmission of data

SPI_WAIT_TRANSMIT:
; Wait for transmission complete
	in	TEMP,	SPSR0
	sbrs	TEMP,	SPIF0
	rjmp	SPI_WAIT_TRANSMIT

	in	SPI_DATA,	SPDR0		; read data from SPI (also clears flag)

	pop		TEMP

	ret

;*************************************************************

WAIT:

	push	TEMP

	ldi	TEMP,	$40			

WAIT_LOOP:
	dec	TEMP
	brne	WAIT_LOOP

	pop	TEMP

	ret

;**********************************************************
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well that was a giant step in the right direction. I took LD high after each 16 bit write instruction and now all the segments are turning on. Still not exactly what I'm after as it should be displaying 0 through 7 on the displays, but at least I'm getting closer.

Thanks for the guidance! - Matt

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is the speed of your AVR?
The wait loop is very short so what you may be seeing is the code being executed and the display is changing so fast all the segments look like they are on at once.
I have not looked at your pdf so I am guessing.

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have it all going now. Turns out I did in fact need to bring LD high after each 16 bit write (on other SPI devices I've used you can leave it low for the entire comms cycle). That took care of turning it on. Then I wasn't able to have individual numbers because I had the test mode (turn on all leds) enabled. I thought maybe if you wrote a number to the display it would override that command but it seems not. Once I turned off test mode my numbers appeared.

Everything is working now!

Thanks heaps guys for assisting along the way. It's always appreciated.

Matt