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


Closed Thread
Results 1 to 36 of 36

Hybrid View

  1. #1
    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?

    Display is ordered from www.fasttech.com. I have not ordered from them before so do not know what the service is like yet.
    I have a PIC18F2550 with USB bootloader to try it on.

    Phil

  2. #2
    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 used this code on my test. When possible try this so.


    '************************************************* ***************
    '* Name : LKM1640.BAS *
    '* Author : Sherbrook' *
    '* Notice : Microcode loader and PicBasic assembler. *
    '* : All Rights Reserved *
    '* Date : 24/7/2013 *
    '* Version : v 2.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    CLEAR ; start with clearing the

    DEFINE OSC 48
    Define RESET_ORG 800h
    DEFINE SHIFT_PAUSEUS 300
    Include "modedefs.bas" ' Include shift modes


    'DEFINE LOADER_USED 1
    ''DEFINE OSC 4
    'DEFINE LCD_DREG PORTA
    'DEFINE LCD_DBIT 4
    'DEFINE LCD_RSREG PORTA
    'DEFINE LCD_RSBIT 2
    'DEFINE LCD_EREG PORTA
    'DEFINE LCD_EBIT 3

    '================================================= =======
    LED1 var PORTA.5
    'strobe var PORTA.4
    SDA VAR PORTB.1
    SCL VAR PORTB.0

    TRISA=%00000000 ' Configura o PortA como Saida
    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 00001111
    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 = %1100-0000 = address $00) - 192
    auto_addr con $44 ' Address of auto-increment mode - 40/64/0100-0000 - 44/68/0100-0100
    'read_mode con $42 ' Address to read switches - 42/66/0100-0010

    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

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

    '----------------------------------------------------------------
    'lcdout $FE,1 ' Clear LCD
    'pause 100
    'lcdout $FE,$80,"Switch "

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

    MAIN:


    for DISP_ADDR = 0 to 16
    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
    ' gosub GET_SWITCH: 'Check switches
    'next

    toggle led1

    goto MAIN

    END
    '----------------------------------------------------------------
    DISPLAY:
    gosub WRITE_MODE

    DISP_ADDR = fix_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

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

    DISP_ADDR = bank + 18
    char = 9 'Print "9"
    gosub lookup_char
    gosub write_display

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

    DISP_ADDR = bank + 22
    char = 11 'Print "11"
    gosub lookup_char
    gosub write_display

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

    DISP_ADDR = bank + 26
    char = 13 'Print "13"
    gosub lookup_char
    gosub write_display

    DISP_ADDR = bank + 28
    char = 14 'Print "14"
    gosub lookup_char
    gosub write_display

    DISP_ADDR = bank + 30
    char = 15 'Print "15"
    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

    '----------------------------------------------------------------
    BLINK_LED_START:
    high led1
    pause 200

    low led1
    pause 100

    high led1
    pause 200

    low led1
    pause 100

    high led1
    pause 200

    low led1
    pause 100
    return

    '================================================= ================

  3. #3
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

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

    jefrem

    It may make little difference but try removing the colons after the gosubs in the following lines:
    Code:
     gosub BLINK_LED_START:
     gosub clear_char: 'Clear 7 seg displays & LEDs
     gosub display: 'Write Chars to 7 seg display

    Norm

  4. #4
    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 Norm, I will change this your tips and return.

  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?

    Hi Norm, I tried this new change but not worked.

    Regards,

  6. #6
    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?

    Just out of curiousity, what does this line do in your code?

    Define RESET_ORG 800h

  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, This "Define RESET_ORG 800h" line is used for Microchip USB bootloader.

    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 : 0

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