Serout code space


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: Serout code space

    asm version 52 words

    Code:
    #CONFIG
        __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & _CP_OFF
    #ENDCONFIG
    DEFINE OSC 8 'LETS PBP KNOW WE WILL BE RUNNING AT 8MHZ
    
    'PIN DEFENITIONS
    '
    'GP3 
    'GP4 USED FOR TRIGGER INPUT
    'GP5 USED FOR LED
    'SET UP THE  REGISTERS
    OSCCON = %01110001  '8MHZ INTERNAL CLOCK USED
    CMCON0 = %00000111 'CIN PINS ARE I/O, COUT PIN IS I/O
    TRISIO = %00111010 ' GP2  OUTPUT THE REST ARE INPUTS 
    ANSEL = 0 'NO ANALOG PORTS - ALL DIGITAL
    WPU = %00010000 'GP4 WEAK PULL UP ENABLED.
        
    '    DEFINE DEBUG_REG GPIO
    '    DEFINE DEBUG_BIT 2
    '    DEFINE DEBUG_BAUD 9600
    '    DEFINE DEBUG_MODE 0
    ''    LATB.7=1
    'PBP software serial out 8N1
    delay var byte bank0 ' set baud rate delay
    txbyte var byte bank0' byte to send
    bcount var byte bank0' counter
    serpin var gpio.0
    ; set serial delay for   9600b
    main:
    txbyte = "H"
    GOSUB serialout
    txbyte = "E"
    GOSUB serialout
    txbyte = "L"
    GOSUB serialout
    txbyte = "L"
    GOSUB serialout
    txbyte = "O"
    GOSUB serialout
    txbyte = $20 ' space
    GOSUB serialout
     
    goto main
     
    
     serialout:
    asm 
     movlw 8
     movwf _bcount 
     bcf     GPIO ,0
     call pausedelay
    sendbyte
     btfss  _txbyte ,0
     goto snd0
     bsf   GPIO ,0
     goto sndd
    snd0 
     bcf   GPIO ,0
    sndd
     rrf _txbyte ,F
     call pausedelay
     decfsz _bcount ,F
     goto sendbyte
     bsf GPIO ,0
    pausedelay
     movlw 67
     movwf _delay 
    zpausedelay
     decfsz _delay  ,F
     goto zpausedelay
     return
    endasm
    Warning I'm not a teacher

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: Serout code space

    printout from pickit2
    Attached Images Attached Images  
    Warning I'm not a teacher

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Serout code space

    Thanks for running it That’s getting worthwhile then. Using Pauseus in the first post would have added code to it.

    I might as well have a shot at the serial input over the next few days then.
    Basically I did this on dspic in C, and it wrote easily into PBP as well.
    The pic at the receive end is supposed to be 16F628A in PBP/asm.

    My mp3 player serial spits out the artist & title info from the ID tags as tracks are skipped (that much is working).
    Then the 16F628A is supposed to receive the serial, and transmit IR to an electronic sign the same way a user would normally use a remote to reprogram the scrolling message

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Serout code space

    This time going for serial input of a string terminated with either 0x00 or 0x0D (or any value below 0x20 really) into an array.
    So far one byte, and untested, but I do have a PBP program on 16F628A ready to test and use it when done.
    It’s on the receive side where I want serene replaced because I can keep going with my own data until the program memory is full.

    Code:
    rxbyte var byte
    count var byte
    delay var byte
    shortdelay var byte
    
    delay = 100 ‘ actual serial timing
    shortdelay = 50 ‘ time/2
    
    
    serinbyte:
    IF PORTB.1 = 1 THEN
    ‘ optional countdown to timeout here
    GOTO serinbyte
    ENDIF
    pauseus delay
    pauses shortdelay
    FOR count = 0 TO 7
    rxbyte.bit7 = PORTB.1
    rxbyte = rxbyte >> 1
    pauseus delay
    NEXT count
    pauses shortdelay
    rxbyte = rxbyte ^ $FF
    return

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: Serout code space

    i'd bet this won't stack_up any better than debug either as is

    until the program memory is full.
    sram ?
    Warning I'm not a teacher

  6. #6
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Serout code space

    Storing data in program memory until full yes.

    Probably not like this, but I'd rather have the whole thing work in PBP
    before doing any of it in asm.
    Hserout of course will beat both of them,
    but sometimes you want all eight bits of Portb for something else.

Similar Threads

  1. Working code but my layman approach uses too much code space
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th December 2012, 20:44
  2. I'm running out of code space example.
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st June 2010, 20:33
  3. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  4. Need more code space
    By Sphere in forum General
    Replies: 2
    Last Post: - 19th September 2005, 20:49
  5. Need more code space
    By ghutchison in forum General
    Replies: 1
    Last Post: - 12th February 2005, 20:54

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