Its "02 June 2006" !


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2005
    Posts
    21

    Default Its "02 June 2006" !

    I have trying everything to get a the formant of a 1302 to display at month.
    ie: "02/10/06" Should be " 02 October 2006 "!
    Anyone have an "Code Sniplet" That I can lool at?
    "Select case" is a Code HOG!
    Here is my code.

    Printit:
    SerOut2 SO,16468,["TIME: ",HEX2 hh,":",HEX2 mm,":",HEX2 ss,10,13]
    Pause 500
    Select Case mo
    'Case mo=01
    ' SerOut2 SO,16468,[HEX2 day," January, 20",HEX2 yr,13]
    'Case mo=02
    'SerOut2 SO,16468,[HEX2 day," Febuary, 20",HEX2 yr,13]
    'Case mo=03
    'SerOut2 SO,16468,[HEX2 day," March, 20",HEX2 yr,13]
    'Case mo=04
    'SerOut2 SO,16468,[HEX2 day," April, 20",HEX2 yr,13]
    'Case mo=05
    'SerOut2 SO,16468,[HEX2 day," May, 20",HEX2 yr,13]
    Case mo=$06
    SerOut2 SO,16468,[HEX2 day," June, 20",HEX2 yr,13]
    Case mo=$07
    SerOut2 SO,16468,[HEX2 day," July, 20",HEX2 yr,13]
    Case mo=$08
    SerOut2 SO,16468,[HEX2 day," Augest, 20",HEX2 yr,13]
    Case mo=$09
    SerOut2 SO,16468,[HEX2 day," Setember, 20",HEX2 yr,13]
    Case mo=$10
    SerOut2 SO,16468,[HEX2 day," October, 20",HEX2 yr,13]
    Case mo=$11
    SerOut2 SO,16468,[HEX2 day," November, 20",HEX2 yr,13]
    Case mo=$12
    SerOut2 SO,16468,[HEX2 day," December, 20",HEX2 yr,13]
    End Select
    Pause 1000
    SerOut2 SO,16468,[" momth= ",HEX2 mo,13,12]
    Kman

  2. #2
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Just a quick comment before I get back to work...

    The code hog is all those SEROUT commands! Your duplicating the Day and Year portion of the commands 12 times!!!! Eliminate this by doing the day before the case select, and the the year afterwards.

    Steve

  3. #3
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    I don't know what pic you are using, but here is a stab at one technique to help you out. It worked on my 18F series pic just fine.

    But fisrt look at Darrel Taylors technique on how to store and retrieve strings in Code Space. This will help you understand what I did. If you are using a 16F, you will need to read this to modify the code.

    Not saying this is the most efficient method, but it's what I came up with at the end of a long day on the quick.

    Code:
    Month_addr     var word
    CntMonthletters var byte
    MonthOut       var byte
    MonthOffset    var byte
    
    MonthString:
    @ da "January  "
    @ da "February "
    @ da "March    "
    @ da "April    "
    @ da "May      "
    @ da "June     "
    @ da "July     "
    @ da "August   "
    @ da "September"
    @ da "October  "
    @ da "November "
    @ da "December "
    
    '------------GetAddress Macro - Location insensitive -------------------------
    ASM
    GetAddress macro Label, Wout       ; Returns the Address of a Label as a Word
        CHK?RP Wout
        movlw low Label
        movwf Wout
        movlw High Label
        movwf Wout + 1
        endm
    ENDASM
    
    
    @         GetAddress _MonthString, _Month_addr        ' Get address of String
    
    
    '-----------------------------------------------------------------------------
    '
    '
    '  Whatever code for main program
    '
    '
    '
    '
    
    'Start your printout here after any other code
    Printit:
    SerOut2 SO,16468,["TIME: ",HEX2 hh,":",HEX2 mm,":",HEX2 ss,10,13]
    Pause 500
    SerOut2 SO,16468,[HEX2 day," "]
    'Printout the stored Month Strings
              monthoffset = ((mo & %00001111) + (10 * (mo >> 4)) - 1) * 10
              for CntMonthletters = 0 to 8
                   Readcode (Month_addr + monthoffset + CntMonthletters), monthout
                   IF monthout = " "  THEN GOTO QuitMonthPrint
                   SerOut2 SO,16468, [monthout]           
              next CntMonthletters
    QuitMonthPrint: 
    SerOut2 SO,16468,[" 20",HEX2 yr,13] 
    End Select
    Pause 1000 
    SerOut2 SO,16468,[" momth= ",HEX2 mo,13,12]
    HTH,
    Steve

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yup, or use almost the same method but load your strings in the internal EEPROM. you need 9 bytes*12 months=108.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    A slight refinement to the previous code. I eliminated the macro and made the starting address a constant. Saves a little space. Again, needs a slight modifaction to unpack the character if using a 16F. (I might get to that example later)

    Code:
    ;Removed variable declaration
    CntMonthletters var byte
    MonthOut       var byte
    MonthOffset    var byte
    
    MonthString:
    @ da "January  "
    @ da "February "
    @ da "March    "
    @ da "April    "
    @ da "May      "
    @ da "June     "
    @ da "July     "
    @ da "August   "
    @ da "September"
    @ da "October  "
    @ da "November "
    @ da "December "
    
    ;Added 2 lines for new constant
    Month_addr CON EXT
    @Month_addr EQU _MonthString
    
    ;Removed the macro and the macro call
    
    '-----------------------------------------------------------------------------
    '
    '
    '  Whatever code for main program
    '
    '
    '
    '
    
    'Start your printout here after any other code
    Printit:
    SerOut2 SO,16468,["TIME: ",HEX2 hh,":",HEX2 mm,":",HEX2 ss,10,13]
    Pause 500
    SerOut2 SO,16468,[HEX2 day," "]
    'Printout the stored Month Strings
              monthoffset = ((mo & %00001111) + (10 * (mo >> 4)) - 1) * 10
              for CntMonthletters = 0 to 8
                   Readcode (Month_addr + monthoffset + CntMonthletters), monthout
                   IF monthout = " "  THEN GOTO QuitMonthPrint
                   SerOut2 SO,16468, [monthout]           
              next CntMonthletters
    QuitMonthPrint: 
    SerOut2 SO,16468,[" 20",HEX2 yr,13] 
    ;This should have been removed in the original!! -->  End Select
    Pause 1000 
    SerOut2 SO,16468,[" momth= ",HEX2 mo,13,12]
    Steve
    Last edited by SteveB; - 4th October 2006 at 04:22.

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