[QUOTE=jefrem;121502]Possible is programing TM1640 Display with PicBasic Pro? How???


I have this code, but does not work. Someone can help me?

'************************************************* ***************
'* Name : TM1640-demo.pbp *
'* Author : Joćo Efrem *
'* Notice : Copyright (c) 2013 JOĆO EFREM @ 2012 *
'* : All Rights Reserved *
'* Date : 22/7/2013 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
CLEAR ; start with clearing the
DEFINE OSC 48
DEFINE RESET_ORG 800h

Seg_nr var Byte
Seg_data var Byte
Info var Byte
T var Byte
Test var Byte
Temp var Byte
LED1 var PORTC.5

Pin_clk var Portb.0 ' TM1640 clock
Pin_data var Portb.1 ' TM1640 data

TRISA=%11111111 ' Port PortA as Input
TRISB=%00000000 ' Port PortB as Output
TRISC=%00000000 ' Port PortC as Output

INTCON2.7 = 1 ; Turn Pull Up Resitor (PORTB Only) 0=Enable/1=Desable
ADCON1 = %00001111 ; Sets all ports to digital
PORTA = %00000000 ; Turn off all PortA
PORTB = %00000000 ; Turn off all PortB
PORTC = %00000000 ; Turn off all PortC

Gosub Tm1640_init ' Light Intensity of display
pause 100

main:


For Temp = 0 To 15
Seg_nr = Temp
Seg_data = Temp
Gosub Tm1640
Next Temp

TOGGLE LED1 ' This normally functioning LED1

goto main

'************************************************* *****************************
'*** Routin TM1640 ***
'*** ***
'*** There two variable. ***
'*** Seg_nr = display number 0-15 (16 Displays) ***
'*** Seg_data = Value send for display (7 Segment date) ***
'************************************************* *****************************
Tm1640:

If Seg_nr > 15 Then Return
If Seg_data > 16 Then Seg_data = 16 ' = Blank Display

gosub DisplayNumberSegment

Info = 68
Gosub Tm1640_zend

high Pin_clk : high Pin_data

Info = Seg_nr + 192 ' Display position (+ 192)
Gosub Tm1640_zend

Info = Seg_data ' Number date to write in display
Gosub Tm1640_zend


high Pin_clk : high Pin_data

Return

'************************************************* *****************************
'*** Send display date and clock Routine ***
'************************************************* *****************************
Tm1640_zend:

low Pin_clk : low Pin_data ' Put low signal in Pin_clk and Pin_data

For T = 1 To 8 ' Test bitwise and send for 'Pind_data' the state of each bit.
Test = Info And 1
if test = 1 then
high pin_data
else
low pin_data
endif
info = info >> 1
high Pin_clk ' Send the pulse clock(Pin_clk) + date(Pin_data)
low Pin_clk
Next T

Return

'************************************************* *****************************
'*** INIT - Light Intensity of display Routine ***
'************************************************* *****************************
Tm1640_init:

Info = 138 ' 143 = fully Light Intensity, 138 = 4/16e
Gosub Tm1640_zend

high Pin_clk : high Pin_data

Return

'************************************************* *****************************
'*** Show the display numbers 0-16(F) on 16 display ***
'************************************************* *****************************

DisplayNumberSegment: 'Display without decimal point
Lookup Seg_data,[$3F,$6,$5B,$4F,$66,$6D,$7D,$7,$7F,$67,$77,$7C,$58, $5E,$79,$71,0],Seg_data '
return

End 'end program