TM1640 (16 digit display) with PicBAsic Pro, possible is? How?


Closed Thread
Results 1 to 36 of 36

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Location
    Manaus - Brazil
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: TM1640 (16 digit display) with PicBAsic Pro, possible is? How?

    Hello, Sherbrook.

    I made change below but yet not works. I will buy another display, I thing this display is wrong, but I don't have sure.


    '************************************************* ***************
    '* Name : LKM1638.BAS *
    '* Author : Sherbrook' *
    '* Notice : Microcode loader and PicBasic assembler. *
    '* : All Rights Reserved *
    '* Date : 24/7/2013 *
    '* Version : v 2.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    '@ DEVICE PIC16F873A, XT_OSC 'Xtal OSC
    '@ DEVICE PIC16F873A, WDT_OFF 'WDT off
    '@ DEVICE PIC16F873A, PWRT_ON 'Power-up timer on
    '@ DEVICE PIC16F873A, BOD_OFF 'Brown-out detect off
    CLEAR ; start with clearing the
    DEFINE OSC 48
    Define RESET_ORG 800h


    'strobe var PORTA.4
    sda VAR PORTB.1
    scl VAR PORTB.0

    TRISA=%11111111 ' Configura o PortA como Entrada
    TRISB=%00000000 ' Configura o PortB como Saida
    TRISC=%00000000 ' Configura o PortC como Saida

    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
    '================================================= =======

    'TRISC = %00000000
    'TRISB = %00000001 ' LCD display / I/R input
    'TRISA = %11000000 ' A.6 & A.7 Bootloader
    'ADCON1 = %00000110 ' PortA all digital

    fix_addr con $C0 ' Start address of 7 segs & LEDs '($C0 = %11000000 = address $00)
    auto_addr con $40 ' Address of auto-increment mode (Change to $44-IC1640)
    'read_mode con $42 ' Address to read switches

    char var byte ' LOOKUP offset for 7 seg code
    disp_addr var byte ' Offset from display start address (ODD = LED, EVEN = 7seg)
    data_io var byte ' Data IN / OUT
    disp_brit var byte ' Display brightness
    seg_val var byte ' Code to send to 7 seg displays LEDs 0 = OFF, 1 = RED, 2 = GREEN
    bank var byte ' 0 = Left 7 segment, 2 = next segment ...... 14 = Right 7 segment
    'sw1 var byte ' Byte 1 of switch read
    'sw2 var byte ' Byte 2 of switch read
    'sw3 var byte ' Byte 3 of switch read
    'sw4 var byte ' Byte 4 of switch read
    'switch var byte ' Switch pressed as binary number
    counter var byte ' General counter
    counter1 var byte

    'strobe = 1 ' Set strobe pin high
    SDA = 1 ' Set data pin high
    SCL = 1 ' Set clock pin high
    disp_brit = $88 ' Set minimum brightness (Max = $8F)
    bank = 0
    DISP_ADDR = 0

    '----------------------------------------------------------------
    gosub clear_char: 'Clear 7 seg displays & LEDs
    gosub display: 'Write Chars to 7 seg display

    MAIN:

    for DISP_ADDR = 1 to 15 step 2
    gosub write_display 'Write to LEDs display
    seg_val = seg_val + 1
    if seg_val > 2 then seg_val = 0
    next

    for counter1 = 0 to 50 'Pause for 1 sec
    pause 20
    next

    goto MAIN:

    end
    '----------------------------------------------------------------
    DISPLAY:
    gosub WRITE_MODE:
    DISP_ADDR = bank + 0
    char = 0 'Print "0"
    gosub lookup_char:
    gosub write_display:

    DISP_ADDR = bank + 2
    char = 1 'Print "1"
    gosub lookup_char:
    gosub write_display:

    DISP_ADDR = bank + 4
    char = 2 'Print "2"
    gosub lookup_char:
    gosub write_display:

    DISP_ADDR = bank + 6
    char = 3 'Print "3"
    gosub lookup_char:
    gosub write_display:

    DISP_ADDR = bank + 8
    char = 4 'Print "4"
    gosub lookup_char:
    gosub write_display:

    DISP_ADDR = bank + 10
    char = 5 'Print "5"
    gosub lookup_char:
    gosub write_display:

    DISP_ADDR = bank + 12
    char = 6 'Print "6"
    gosub lookup_char:
    gosub write_display:

    DISP_ADDR = bank + 14
    char = 7 'Print "7"
    gosub lookup_char:
    gosub write_display:
    gosub display_brit: 'Set Display brightness

    return

    '----------------------------------------------------------------
    CLEAR_CHAR: 'Clear LEDs & 7 seg displays
    gosub write_mode:

    'STROBE = 0
    data_io = FIX_ADDR 'Set start address
    gosub send_char:

    for counter = 1 to 16
    data_io = 0 'Blank display
    gosub send_char:
    next

    'Strobe = 1

    return

    '----------------------------------------------------------------
    CLEAR_LEDS: 'Clear LEDs only
    gosub write_mode:

    for DISP_ADDR = 1 to 15 step 2
    SEG_VAL = 0 'Turns LEDs OFF
    gosub write_display:
    next

    gosub display_brit 'Set brightness

    return

    '----------------------------------------------------------------
    SEND_CHAR:
    shiftout SDA,SCL,4,[data_io]'LSB first, CLOCK idle HIGH
    return

    '----------------------------------------------------------------
    LOOKUP_CHAR:
    ' lookup char,[1,2,4,8,16,32,64,128],seg_val
    ' Turns on a different segment on each display
    lookup char,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F,$77,$7C,$5 8,$5E,$79,$71,$0],SEG_VAL
    'Value for 0,1,2,3,4,5,6,7,8,9,A,b,c,d,E,F,(Blank)
    return

    '----------------------------------------------------------------
    DISPLAY_BRIT:
    data_io = disp_brit
    'STROBE = 0
    gosub send_char:

    'STROBe = 1

    return

    '----------------------------------------------------------------
    WRITE_DISPLAY:
    data_io = FIX_ADDR + DISP_ADDR
    'strobe = 0
    gosub send_char:

    data_io = SEG_VAL
    gosub send_char:

    'STROBE = 1
    gosub display_brit:

    return

    '----------------------------------------------------------------
    WRITE_MODE:
    DATA_IO = AUTO_ADDR
    'strobe = 0
    gosub send_char:

    'strobe = 1

    return
    '================================================= ================

    Thank you for your attention.

  2. #2
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: TM1640 (16 digit display) with PicBAsic Pro, possible is? How?

    Every link I find about this display is coupled with Arduino and they always reference a library. I wasn't able to find any libraries written for PBP so it might never work on Basic until you can find the library for it.

  3. #3
    Join Date
    Aug 2011
    Location
    Manaus - Brazil
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: TM1640 (16 digit display) with PicBAsic Pro, possible is? How?

    I continuous search article about this Display (TM1640) on internet, if find any thing about this device, I post he!

  4. #4
    Join Date
    Oct 2011
    Posts
    54


    Did you find this post helpful? Yes | No

    Default Re: TM1640 (16 digit display) with PicBAsic Pro, possible is? How?

    I see you are using USB loader and are stuck with 48mHz. Perhaps this is too fast for TM1640. Have you got a slower PIC to try with.
    My code does work at 4mHz.
    Have you got the datasheet for TM1640?
    Phil

  5. #5
    Join Date
    Aug 2011
    Location
    Manaus - Brazil
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: TM1640 (16 digit display) with PicBAsic Pro, possible is? How?

    Exact, I've use Bootloader with 48MHz. I have the Datasheet. I'll try with 16F628A and return.

  6. #6
    Join Date
    Oct 2011
    Posts
    54


    Did you find this post helpful? Yes | No

    Default Re: TM1640 (16 digit display) with PicBAsic Pro, possible is? How?

    Hi Joćo
    Have ordered a JY-MCU 16X display. I should get it in about 2 weeks. Will let you know how I get on.
    Phil

  7. #7
    Join Date
    Aug 2011
    Location
    Manaus - Brazil
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: TM1640 (16 digit display) with PicBAsic Pro, possible is? How?

    Hi Phil,

    I tried buy other display on dx.com but is sold out. Where you buy? Do you have an PIC18F with clock 48Mhz famile for make this new test ?

    Regards,

Similar Threads

  1. HSEROUT full 3 digit display of variable howto ?
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th October 2008, 13:53
  2. Replies: 2
    Last Post: - 14th July 2008, 22:11
  3. Replies: 2
    Last Post: - 22nd January 2008, 14:25
  4. How to display dot on 7-seg , 4 digit
    By chai98a in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 19th January 2007, 18:17
  5. SMART Serial 4 Digit LCD Display (SMARD4)
    By paul borgmeier in forum Adverts
    Replies: 0
    Last Post: - 5th January 2005, 05:50

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts