Question

Compile .asm to .hex (for a PIC16F84)

Asked by: wheezle

Simple to do:  I want the .hex file for the following .asm code so that I can program my PIC16F84 chip with it.  Can someone copy and paste this into their MPLAB IDE and spit out the hex for me please?  I know it must sound lazy but please understand first that I can't install the software on my computer, nor have I ever used it, and I REALLY want this code A.S.A.P.!

Please help me -- thank you!  :D

(The .asm file is available from http://www.hamradio-online.com/1999/feb/mdecoder.html, written by Lawrence Foltzer back in 1998.)

If you need the p16F84.inc file, I believe you can get it here:
http://oh3tr.ele.tut.fi/~ftp/repeater/logic/oh3hrk/P16F84.INC






;**********************************************************************
;       Filename:       picmrsrc.asm
;       Date:   Wednesday, December 30, 1998 10:28
;       File Version:  
;       Author: Lawrence Foltzer
;       Size:           365 bytes
;**********************************************************************
        list    p=16F84 ; list directive to define processor
        #include        <p16F84.inc>        ; processor specific variable definitions

       __CONFIG        _CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC
; timing based on 1.12MHz RC oscillator configuration using 5.1Kohm + 100pf
;**********************************************************************
;***** application specific equates
E       equ     .4
R_W     equ     .5
RS      equ     .6
code_in equ     .7      ; PORTB,7 (also ICSPDATA and tone LED)
busy    equ     .3
BusyChk equ     B'00100000'
FuncSet41       equ     0x22    ; get its attention
FuncSet42       equ     0x20    ; get it in right mode
DisplayOn       equ     0x0c
EntryMode       equ     0x06
InitDdRam       equ     0x27
Ddra4Input      equ     B'00001111'
led     equ     .4      ; RA4 runs LED
Ddrb4Input      equ     B'10001111'
Ddrb4Output     equ     B'10000000'
ReadCntrl       equ     B'10100000'
pad1    equ     0x68    ; = 104
noise   equ     0x02    ; 16 milliseconds or less is noise
Ithres  equ     0x80
tabsize equ     .4
; optest        equ     .16

;**********************************************************************
;***** ram allocation
        ORG     0x0c

temp_w  res     1
temp_status     res     1

flags   res     1
; "flags" bit assignment follows
DitDah  equ     7       ; set (1) for DIT, clear (0) for DAH
overflow        equ     6       ; slow code can cause counter overflow

PortaImage      res     1
PortbImage      res     1

timecnt res     1       ; this is increment in the ISR
period  res     1       ; and transferred here on edge detection
thres   res     1       ; computed symbol type decision threshold

codeword        res     1       ; 1/0 representation of mickey morse

ditptr  res     1       ; pointer to ditvals buffer
ditsum  res     1
ditave  res     1
ditvals res     tabsize

dahptr  res     1       ; pointer th dahvals buffer
dahsum  res     1
dahave  res     1
dahvals res     tabsize

stack   res     1       ; available RAM
;**********************************************************************
        org     0x000
boot    goto    init
; ********************************************************************************
; this IRQ is entered every 4 milliseconds
        org     0x004
ISR     movwf   temp_w
        movf    STATUS,W
        movwf   temp_status
        incf    timecnt,1
        btfss   STATUS,Z
        goto    isrjmp
        bsf     flags,overflow
        decf    timecnt,1
isrjmp  movlw   0x74    ; 116
        movwf   TMR0
        bcf     INTCON,T0IF
exit1   movf    temp_status,W
        movwf   STATUS
        swapf   temp_w,1
        swapf   temp_w,W
        retfie
; ********************************************************************************
; morse tables follow ISR to keep them in 1st page, hopefully.
ditab   clrf    PCLATH
        movf    codeword,W
        andlw   B'00111111'
        addwf   PCL,1
        retlw   " "
        retlw   "e"
        retlw   "a"
        retlw   "i"
        retlw   "w"
        retlw   "r"
        retlw   "u"
        retlw   "s"
        retlw   "j"
        retlw   "p"
        retlw   0x5f
        retlw   "l"
        retlw   0x5f
        retlw   "f"
        retlw   "v"
        retlw   "h"
        retlw   "1"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x7c    ; is "|" rather than "\" end of message
        retlw   0x5f
        retlw   0x5f    ; _ = wait
        retlw   "2"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   "3"
        retlw   "!"     ; acknowledge
        retlw   "4"
        retlw   "5"
        retlw   0x5f
        retlw   "'"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   "."
        retlw   0x5f
        retlw   0x5f
        retlw   0x22    ; quotation mark
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   "_"
        retlw   "?"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   "<"     ; end of work
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f

dahtab  clrf    PCLATH
        movf    codeword,W
        andlw   B'00111111'
        addwf   PCL,1
        retlw   " "
        retlw   "t"
        retlw   "n"
        retlw   "m"
        retlw   "d"
        retlw   "k"
        retlw   "g"
        retlw   "o"
        retlw   "b"
        retlw   "x"
        retlw   "c"
        retlw   "y"
        retlw   "z"
        retlw   "q"
        retlw   0x5f
        retlw   0x5f
        retlw   "6"
        retlw   "="     ; double dash
        retlw   "/"     ; fraction bar
        retlw   0x5f
        retlw   0x5f
        retlw   ">"     ; starting signal
        retlw   "("
        retlw   0x5f
        retlw   "7"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   "8"
        retlw   0x5f
        retlw   "9"
        retlw   "0"
        retlw   0x5f
        retlw   "-"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   ";"
        retlw   0x5f
        retlw   0x5f
        retlw   ")"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   ","
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   ":"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f

; ********************************************************************************
; next is for xtal clock
init    movlw   0x04    ; divide XTAL OSC by 4 and then 32 for 4ms ticks
        option          ; later, load TMR0 with 256-140 and let overflow
; next is for rc clock
;init   movlw   0x02    ; divide RC OSC by 4 and then 8 for ~4ms ticks
;       option          ; later, load TMR0 with 256-140 and let overflow

        movlw   Ddra4Input
        tris    PORTA
        bcf     PORTA,led       ; on initially
        movlw   Ddrb4Input
        tris    PORTB

        clrf    PortbImage
        clrf    PortaImage
dlp1    decfsz  PortaImage,1
        goto    dlp1
        decfsz  PortbImage,1
        goto    dlp1

        call    ChkBusy

        movlw   FuncSet41
        movwf   PORTB
        call    SendCmmd

        movlw   FuncSet42
        movwf   PORTB
        call    SendCmmd
        movlw   DisplayOn
        call    SendCmmd
        movlw   EntryMode
        call    SendCmmd
        movlw   InitDdRam
        call    SendCmmd

        movlw   .13
        movwf   ditptr
        movlw   ditptr
        movwf   FSR
ilp1    incf    FSR,1
        clrf    INDF
        decfsz  ditptr,1
        goto    ilp1

        movlw   0x18
        movwf   thres

        clrf    TMR0
        clrf    flags
        clrf    INTCON
        bsf     INTCON,T0IE
        bsf     INTCON,GIE
; ********************************************************************************

        clrf    PortbImage
        clrf    PortaImage
dlp1    decfsz  PortaImage,1
        goto    dlp1
        decfsz  PortbImage,1
        goto    dlp1

        call    ChkBusy

        movlw   FuncSet41
        movwf   PORTB
        call    SendCmmd

        movlw   FuncSet42
        movwf   PORTB
        call    SendCmmd
        movlw   DisplayOn
        call    SendCmmd
        movlw   EntryMode
        call    SendCmmd




start   btfss   PORTB,code_in
        goto    start   ; receiving a tone, exit on a space
        bsf     PORTA,led
; we are now receiving a space
start2  btfsc   PORTB,code_in
        goto    start2  ; now we wait for a tone to time
; detected the start of a dit or dah
        bcf     PORTA,led       ; light LED
        clrf    timecnt ; reset timer count
db1     movlw   noise   ; debounce (db) tone edge
        subwf   timecnt,W       ; timecnt - noise
        btfss   STATUS,C
        goto    db1
w84spc1 btfss   PORTB,code_in
        goto    w84spc1 ; tone still present
; tone stopped, but this is first so we don't know what it is. we assume it is a dah!
        movf    timecnt,W
        movwf   period
        clrf    timecnt
        bsf     PORTA,led
        movlw   0x01
        movwf   codeword        ; prep for 1st symbol
        movf    thres,W
        subwf   period,W        ; period - thres
        btfsc   STATUS,C
        goto    isadah
isadit  bsf     flags,DitDah
        call    avedit
        goto    mainlp
isadah  bcf     flags,DitDah
        call    avedah
; now we wait for a tone to start so we can see what kind of space just passed
mainlp  btfsc   PORTB,code_in
        goto    mainlp  ; space while set
        movf    timecnt,W
        movwf   period
        clrf    timecnt
; we are timing the current tone period now. so light the LED.
        bcf     PORTA,led       ; let there be light
; ********************************************************************************
; so how long was the space? symbol or char
        movf    thres,W
        subwf   period,W        ; period - thres
        btfss   STATUS,C
        goto    symbolspc
        goto    longspc
longspc rlf     thres,W
        subwf   period,W        ; period - thres
        btfss   STATUS,C
        goto    charspc
        goto    wordspc
; ********************************************************************************
symbolspc       movlw   noise
db3     subwf   timecnt,W       ; timecnt - noise
        btfss   STATUS,C
        goto    db3
db4     btfss   PORTB,code_in
        goto    db4     ; wait for the tone to end
        movf    timecnt,W
        movwf   period
        clrf    timecnt
        bsf     PORTA,led
        movf    thres,W
        subwf   period,W        ; period - thres
        btfsc   STATUS,C
        goto    itsadah
        goto    itsadit
; ********************************************************************************
itsadit call    avedit
        btfsc   flags,DitDah
        bsf     STATUS,C
        btfss   flags,DitDah
        bcf     STATUS,C
        rlf     codeword,1
        goto    mainlp
; ********************************************************************************
itsadah call    avedah
        btfss   flags,DitDah
        bsf     STATUS,C
        btfsc   flags,DitDah
        bcf     STATUS,C
        rlf     codeword,1
        goto    mainlp
; ********************************************************************************
charspc btfsc   flags,DitDah
        goto    ditstart1
;       goto    dahstart1
; ********************************************************************************
dahstart1       call    dahtab
        goto    printit
; ********************************************************************************
ditstart1       call    ditab
printit call    SendText        ; printit, send to LCD
        goto    db1
; ********************************************************************************
wordspc btfsc   flags,DitDah
        goto    ditstart2
;       goto    dahstart2
dahstart2       call    dahtab
doit    call    SendText
        movlw   0x20    ; space
        call    SendText
        goto    db1
ditstart2       call    ditab
        goto    doit
; ********************************************************************************
avedit  movf    ditptr,W
        addlw   ditvals
        movwf   FSR
        movf    INDF,W
        subwf   ditsum,1
        movf    period,W
        movwf   INDF
        addwf   ditsum,1
        rrf     ditsum,W
        movwf   ditave
        rrf     ditave,1
        movlw   0x3f
        andwf   ditave,1
        incf    ditptr,1
        movlw   0x03
        andwf   ditptr,1
        goto    makethres
; ********************************************************************************
avedah  movf    dahptr,W
        addlw   dahvals
        movwf   FSR
        movf    INDF,W
        subwf   dahsum,1
        movf    period,W
        movwf   INDF
        addwf   dahsum,1
        rrf     dahsum,w
        movwf   dahave
        rrf     dahave,1
        movlw   0x3f
        andwf   dahave,1
        incf    dahptr,1
        movlw   0x03
        andwf   dahptr,1
makethres       movf    ditave,W
        subwf   dahave,W
        movwf   thres
        bcf     STATUS,C
        rrf     thres,1
        movf    ditave,W
        addwf   thres,1
        return
; ********************************************************************************
SendText        clrf    PORTB
        bsf     PORTB,RS
        goto    Send1
SendCmmd        clrf    PORTB
Send1   movwf   PortbImage
        swapf   PortbImage,w
        andlw   0x0f
        iorwf   PORTB,1
        bsf     PORTB,E
        bcf     PORTB,E
        movlw   0xf0
        andwf   PORTB,1
        movf    PortbImage,w
        andlw   0x0f
        iorwf   PORTB,1
        bsf     PORTB,E
        bcf     PORTB,E
; ********************************************************************************
ChkBusy movlw   Ddrb4Input
        tris    PORTB
SampleAgain     movlw   ReadCntrl
        movwf   PORTB
        bsf     PORTB,E
        movf    PORTB,w
        movwf   PortbImage
        bcf     PORTB,E
        bsf     PORTB,E
        bcf     PORTB,E
        btfsc   PortbImage,busy
        goto    SampleAgain
        movlw   Ddrb4Output
        tris    PORTB
        return
;**********************************************************************
; this version is based on use of an NE567 tone decoder
; as input filter. decoder output is low when a tone is detected.
; advantages: immunity to adjacent channel signal, and amplitude variation.

; timing considerations, how long is a symbol?
; the reference symbol duration is the DIT!.
; a DAH symbol is 3 DITs long.
; the space between a pair of symbols is 1 DIT long.
; characters are groups of symbols and the spaces between them.
; the space between characters is 3 DITs long.
; the space between words is 5 DITs long.
; there are 50 symbol periods in the reference string: PARIS
; ". _ _ .   . _   . _ .   . .   . . .     "
; so at 12 WPM, we have 600 symbols in 60 seconds, ===> 0.1 sec / symbol
; @ 36 WPM, the shortest (DIT) symbol period is 33ms long.
; ********************************************************************************
; ********************************************************************************
; *****************************************


        end

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-07-12 at 12:26:31ID21056041
Tags

hex

,

asm

Topic

Assembly Programming Language

Participating Experts
1
Points
90
Comments
8

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ASM Translation
    I am currently trying to learn some good asm optimizing techniques for a graphics program I am running, and was wondering if there was a fast way to do what I'm doing below in ASM. (I'm sure there is) for(x=0; x < 320; x++) for(y=0; y < 200; y++) { total_distance=0; fo...
  2. Asm question.
    Hi, I need an example in asm code. could some one write a small dos asm program that uses cmp? Thanks.
  3. ASM to HEX
    Hi, I was wondering where I can find a list of assembler equivilants in hex. I am not sure of the proper name, so searching on altavista didn't turn up much. What I mean is when a program is compiled, assembler is converted to hex. eg. NOP = 90 JNZ = 74 etc, etc... I woul...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: CerfPosted on 2004-07-12 at 14:35:12ID: 11533829

You promise that there is nothing illegal with this code and assume all responsability for actions if any?

If you do, then I'll be more than happy cause I don't know what do you want this decoder for and honestly I don't have the time to investigate right now.

Kind regards,

Cërf.

 

by: CerfPosted on 2004-07-12 at 14:49:52ID: 11533985

Anyway, there is an error on the code

        movlw   Ddra4Input
        tris    PORTA
        bcf     PORTA,led       ; on initially
        movlw   Ddrb4Input
        tris    PORTB

        clrf    PortbImage
        clrf    PortaImage
dlp1  decfsz  PortaImage,1
        goto    dlp1
        decfsz  PortbImage,1
        goto    dlp1

        call    ChkBusy

This is the LST:

********************************************************************************
                    00286
00C5 0190           00287         clrf    PortbImage
00C6 018F           00288         clrf    PortaImage
Error[116]  : Address label duplicated or different in second pass (dlp1)
00C7 0B8F           00289 dlp1    decfsz  PortaImage,1
00C8 28A5           00290         goto    dlp1
00C9 0B90           00291         decfsz  PortbImage,1
00CA 28A5           00292         goto    dlp1
                    00293
00CB 2169           00294         call    ChkBusy

 

by: wheezlePosted on 2004-07-13 at 08:23:48ID: 11539856

Oh wow, I didn't know about that error, I just copied and pasted the code from the website.  As far as I know, there is nothing illegal with this project -- it was even published in a Ham Radio magazine in 1999, so it must be okay.  All the circuit does is hook up a microphone to a radio and listens for any Morse Code (from 6 words/min to 36+) and then it outputs the words it heard on a little LCD display.

My friend and I are trying to learn Morse Code so we can get our 5wpm certificate this summer.  She has already made a couple of little audible clickers to practice with, so I thought it would be cool to make this display circuit and check our progress as we go.  Everything is built and I even have the programmer set up to burn the chip -- the last piece of the puzzle is this little .hex file...

Could you please correct the error, make sure the p16F84.inc file is included in the code, and then list the resultant .hex file here?  I would really appreciate it.
 

 

by: wheezlePosted on 2004-07-13 at 08:39:48ID: 11540060

Okay, nevermind, I found the error and fixed it.

Copy and paste the following is the new code please:




;**********************************************************************
;       Filename:       picmrsrc.asm
;       Date:           Wednesday, December 30, 1998 10:28
;       File Version:  
;       Author:         Lawrence Foltzer
;       Size:           365 bytes
;**********************************************************************
        list    p=16F84 ; list directive to define processor
        #include        <p16F84.inc>        ; processor specific variable definitions

       __CONFIG        _CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC
; timing based on 1.12MHz RC oscillator configuration using 5.1Kohm + 100pf
;**********************************************************************
;***** application specific equates
E               equ     .4
R_W             equ     .5
RS              equ     .6
code_in         equ     .7      ; PORTB,7 (also ICSPDATA and tone LED)
busy            equ     .3
BusyChk         equ     B'00100000'
FuncSet41       equ     0x22    ; get its attention
FuncSet42       equ     0x20    ; get it in right mode
DisplayOn       equ     0x0c
EntryMode       equ     0x06
InitDdRam       equ     0x27
Ddra4Input      equ     B'00001111'
led             equ     .4      ; RA4 runs LED
Ddrb4Input      equ     B'10001111'
Ddrb4Output     equ     B'10000000'
ReadCntrl       equ     B'10100000'
pad1            equ     0x68    ; = 104
noise           equ     0x02    ; 16 milliseconds or less is noise
Ithres          equ     0x80
tabsize         equ     .4
; optest        equ     .16

;**********************************************************************
;***** ram allocation
        ORG     0x0c

temp_w  res     1
temp_status     res     1

flags           res     1
; "flags" bit assignment follows
DitDah          equ     7       ; set (1) for DIT, clear (0) for DAH
overflow        equ     6       ; slow code can cause counter overflow

PortaImage      res     1
PortbImage      res     1

timecnt         res     1       ; this is increment in the ISR
period          res     1       ; and transferred here on edge detection
thres           res     1       ; computed symbol type decision threshold

codeword        res     1       ; 1/0 representation of mickey morse

ditptr          res     1       ; pointer to ditvals buffer
ditsum          res     1
ditave          res     1
ditvals         res     tabsize

dahptr          res     1       ; pointer th dahvals buffer
dahsum          res     1
dahave          res     1
dahvals         res     tabsize

stack           res     1       ; available RAM
;**********************************************************************
        org     0x000
boot    goto    init
; ********************************************************************************
; this IRQ is entered every 4 milliseconds
        org     0x004
ISR     movwf   temp_w
        movf    STATUS,W
        movwf   temp_status
        incf    timecnt,1
        btfss   STATUS,Z
        goto    isrjmp
        bsf     flags,overflow
        decf    timecnt,1
isrjmp  movlw   0x74    ; 116
        movwf   TMR0
        bcf     INTCON,T0IF
exit1   movf    temp_status,W
        movwf   STATUS
        swapf   temp_w,1
        swapf   temp_w,W
        retfie
; ********************************************************************************
; morse tables follow ISR to keep them in 1st page, hopefully.
ditab   clrf    PCLATH
        movf    codeword,W
        andlw   B'00111111'
        addwf   PCL,1
        retlw   " "
        retlw   "e"
        retlw   "a"
        retlw   "i"
        retlw   "w"
        retlw   "r"
        retlw   "u"
        retlw   "s"
        retlw   "j"
        retlw   "p"
        retlw   0x5f
        retlw   "l"
        retlw   0x5f
        retlw   "f"
        retlw   "v"
        retlw   "h"
        retlw   "1"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x7c    ; is "|" rather than "\" end of message
        retlw   0x5f
        retlw   0x5f    ; _ = wait
        retlw   "2"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   "3"
        retlw   "!"     ; acknowledge
        retlw   "4"
        retlw   "5"
        retlw   0x5f
        retlw   "'"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   "."
        retlw   0x5f
        retlw   0x5f
        retlw   0x22    ; quotation mark
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   "_"
        retlw   "?"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   "<"     ; end of work
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f

dahtab  clrf    PCLATH
        movf    codeword,W
        andlw   B'00111111'
        addwf   PCL,1
        retlw   " "
        retlw   "t"
        retlw   "n"
        retlw   "m"
        retlw   "d"
        retlw   "k"
        retlw   "g"
        retlw   "o"
        retlw   "b"
        retlw   "x"
        retlw   "c"
        retlw   "y"
        retlw   "z"
        retlw   "q"
        retlw   0x5f
        retlw   0x5f
        retlw   "6"
        retlw   "="     ; double dash
        retlw   "/"     ; fraction bar
        retlw   0x5f
        retlw   0x5f
        retlw   ">"     ; starting signal
        retlw   "("
        retlw   0x5f
        retlw   "7"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   "8"
        retlw   0x5f
        retlw   "9"
        retlw   "0"
        retlw   0x5f
        retlw   "-"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   ";"
        retlw   0x5f
        retlw   0x5f
        retlw   ")"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   ","
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   ":"
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f
        retlw   0x5f

; ********************************************************************************
; next is for rc clock
init    movlw   0x02    ; divide RC OSC by 4 and then 8 for ~4ms ticks
        option          ; later, load TMR0 with 256-140 and let overflow

        movlw   Ddra4Input
        tris    PORTA
        bcf     PORTA,led       ; on initially
        movlw   Ddrb4Input
        tris    PORTB

        clrf    PortbImage
        clrf    PortaImage
dlp1    decfsz  PortaImage,1
        goto    dlp1
        decfsz  PortbImage,1
        goto    dlp1

        call    ChkBusy

        movlw   FuncSet41
        movwf   PORTB
        call    SendCmmd

        movlw   FuncSet42
        movwf   PORTB
        call    SendCmmd
        movlw   DisplayOn
        call    SendCmmd
        movlw   EntryMode
        call    SendCmmd
        movlw   InitDdRam
        call    SendCmmd

        movlw   .13
        movwf   ditptr
        movlw   ditptr
        movwf   FSR
ilp1    incf    FSR,1
        clrf    INDF
        decfsz  ditptr,1
        goto    ilp1

        movlw   0x18
        movwf   thres

        clrf    TMR0
        clrf    flags
        clrf    INTCON
        bsf     INTCON,T0IE
        bsf     INTCON,GIE
; ********************************************************************************

start   btfss   PORTB,code_in
        goto    start   ; receiving a tone, exit on a space
        bsf     PORTA,led
; we are now receiving a space
start2  btfsc   PORTB,code_in
        goto    start2  ; now we wait for a tone to time
; detected the start of a dit or dah
        bcf     PORTA,led       ; light LED
        clrf    timecnt ; reset timer count
db1     movlw   noise   ; debounce (db) tone edge
        subwf   timecnt,W       ; timecnt - noise
        btfss   STATUS,C
        goto    db1
w84spc1 btfss   PORTB,code_in
        goto    w84spc1 ; tone still present
; tone stopped, but this is first so we don't know what it is. we assume it is a dah!
        movf    timecnt,W
        movwf   period
        clrf    timecnt
        bsf     PORTA,led
        movlw   0x01
        movwf   codeword        ; prep for 1st symbol
        movf    thres,W
        subwf   period,W        ; period - thres
        btfsc   STATUS,C
        goto    isadah
isadit  bsf     flags,DitDah
        call    avedit
        goto    mainlp
isadah  bcf     flags,DitDah
        call    avedah
; now we wait for a tone to start so we can see what kind of space just passed
mainlp  btfsc   PORTB,code_in
        goto    mainlp  ; space while set
        movf    timecnt,W
        movwf   period
        clrf    timecnt
; we are timing the current tone period now. so light the LED.
        bcf     PORTA,led       ; let there be light
; ********************************************************************************
; so how long was the space? symbol or char
        movf    thres,W
        subwf   period,W        ; period - thres
        btfss   STATUS,C
        goto    symbolspc
        goto    longspc
longspc rlf     thres,W
        subwf   period,W        ; period - thres
        btfss   STATUS,C
        goto    charspc
        goto    wordspc
; ********************************************************************************
symbolspc       movlw   noise
db3     subwf   timecnt,W       ; timecnt - noise
        btfss   STATUS,C
        goto    db3
db4     btfss   PORTB,code_in
        goto    db4     ; wait for the tone to end
        movf    timecnt,W
        movwf   period
        clrf    timecnt
        bsf     PORTA,led
        movf    thres,W
        subwf   period,W        ; period - thres
        btfsc   STATUS,C
        goto    itsadah
        goto    itsadit
; ********************************************************************************
itsadit call    avedit
        btfsc   flags,DitDah
        bsf     STATUS,C
        btfss   flags,DitDah
        bcf     STATUS,C
        rlf     codeword,1
        goto    mainlp
; ********************************************************************************
itsadah call    avedah
        btfss   flags,DitDah
        bsf     STATUS,C
        btfsc   flags,DitDah
        bcf     STATUS,C
        rlf     codeword,1
        goto    mainlp
; ********************************************************************************
charspc btfsc   flags,DitDah
        goto    ditstart1
;       goto    dahstart1
; ********************************************************************************
dahstart1       call    dahtab
        goto    printit
; ********************************************************************************
ditstart1       call    ditab
printit call    SendText        ; printit, send to LCD
        goto    db1
; ********************************************************************************
wordspc btfsc   flags,DitDah
        goto    ditstart2
;       goto    dahstart2
dahstart2       call    dahtab
doit    call    SendText
        movlw   0x20    ; space
        call    SendText
        goto    db1
ditstart2       call    ditab
        goto    doit
; ********************************************************************************
avedit  movf    ditptr,W
        addlw   ditvals
        movwf   FSR
        movf    INDF,W
        subwf   ditsum,1
        movf    period,W
        movwf   INDF
        addwf   ditsum,1
        rrf     ditsum,W
        movwf   ditave
        rrf     ditave,1
        movlw   0x3f
        andwf   ditave,1
        incf    ditptr,1
        movlw   0x03
        andwf   ditptr,1
        goto    makethres
; ********************************************************************************
avedah  movf    dahptr,W
        addlw   dahvals
        movwf   FSR
        movf    INDF,W
        subwf   dahsum,1
        movf    period,W
        movwf   INDF
        addwf   dahsum,1
        rrf     dahsum,w
        movwf   dahave
        rrf     dahave,1
        movlw   0x3f
        andwf   dahave,1
        incf    dahptr,1
        movlw   0x03
        andwf   dahptr,1
makethres       movf    ditave,W
        subwf   dahave,W
        movwf   thres
        bcf     STATUS,C
        rrf     thres,1
        movf    ditave,W
        addwf   thres,1
        return
; ********************************************************************************
SendText        clrf    PORTB
        bsf     PORTB,RS
        goto    Send1
SendCmmd        clrf    PORTB
Send1   movwf   PortbImage
        swapf   PortbImage,w
        andlw   0x0f
        iorwf   PORTB,1
        bsf     PORTB,E
        bcf     PORTB,E
        movlw   0xf0
        andwf   PORTB,1
        movf    PortbImage,w
        andlw   0x0f
        iorwf   PORTB,1
        bsf     PORTB,E
        bcf     PORTB,E
; ********************************************************************************
ChkBusy movlw   Ddrb4Input
        tris    PORTB
SampleAgain     movlw   ReadCntrl
        movwf   PORTB
        bsf     PORTB,E
        movf    PORTB,w
        movwf   PortbImage
        bcf     PORTB,E
        bsf     PORTB,E
        bcf     PORTB,E
        btfsc   PortbImage,busy
        goto    SampleAgain
        movlw   Ddrb4Output
        tris    PORTB
        return
;**********************************************************************
; this version is based on use of an NE567 tone decoder
; as input filter. decoder output is low when a tone is detected.
; advantages: immunity to adjacent channel signal, and amplitude variation.

; timing considerations, how long is a symbol?
; the reference symbol duration is the DIT!.
; a DAH symbol is 3 DITs long.
; the space between a pair of symbols is 1 DIT long.
; characters are groups of symbols and the spaces between them.
; the space between characters is 3 DITs long.
; the space between words is 5 DITs long.
; there are 50 symbol periods in the reference string: PARIS
; ". _ _ .   . _   . _ .   . .   . . .     "
; so at 12 WPM, we have 600 symbols in 60 seconds, ===> 0.1 sec / symbol
; @ 36 WPM, the shortest (DIT) symbol period is 33ms long.
; *********************************************************************

        end

 

by: CerfPosted on 2004-07-13 at 10:21:41ID: 11541092

:020000009C283A
:080008008C0003088D00910A31
:10001000031D0C280E179103743081000B110D087D
:1000200083008C0E0C0E09008A0114083F398207E8
:100030002034653461346934773472347534733400
:100040006A3470345F346C345F34663476346834C8
:1000500031345F345F345F345F347C345F345F3419
:1000600032345F345F345F343334213434343534E4
:100070005F3427345F345F345F345F345F345F3420
:100080005F345F342E345F345F3422345F345F3446
:100090005F345F345F343F345F345F345F345F34E8
:1000A0005F345F343C345F345F345F345F345F34DB
:1000B0008A0114083F398207203474346E346D3459
:1000C00064346B3467346F34623478346334793435
:1000D0007A3471345F345F3436343D342F345F34D6
:1000E0005F343E3428345F3437345F345F345F34F8
:1000F00038345F34393430345F342D345F345F3416
:100100005F345F345F345F345F345F343B345F347B
:100110005F3429345F345F345F345F345F342C34B0
:100120005F345F345F345F343A345F345F345F345C
:100130005F345F345F345F34023062000F3065003B
:1001400005128F30660090018F018F0BA528900B50
:10015000A5285821223086004A21203086004A21D5
:100160000C304A2106304A2127304A210D309500B3
:1001700015308400840A8001950BBA28183093004A
:1001800081018E018B018B168B17861FC5280516E2
:10019000861BC8280512910102301102031CCC28CD
:1001A000861FD02811089200910105160130940095
:1001B000130812020318DF288E171E21E1288E1360
:1001C0002F21861BE12811089200910105121308C6
:1001D0001202031CF128EC28130D1202031C0E2935
:1001E000152902301102031CF228861FF528110878
:1001F000920091010516130812020318072900291D
:100200001E218E1B03148E1F0310940DE1282F2135
:100210008E1F03148E1B0310940DE1288E1B1229D0
:100220005820132914204721CC288E1B1C29582024
:10023000472120304721CC28142018291508183EC2
:10024000840000089602120880009607160C97009A
:10025000970C3F309705950A033095053F291C08F8
:100260001F3E840000089D02120880009D071D0C9F
:100270009E009E0C3F309E059C0A03309C0517088B
:100280001E0293000310930C1708930708008601C1
:1002900006174B2986019000100E0F3986040616AA
:1002A0000612F030860510080F398604061606126D
:1002B0008F306600A03086000616060890000612F1
:0E02C0000616061290195A29803066000800B2
:02400E00F33F7E
:00000001FF

 

by: CerfPosted on 2004-07-13 at 10:22:22ID: 11541104

There you go....
Good luck getting you cetification!

Regards,

Cërf.

 

by: wheezlePosted on 2004-07-14 at 06:54:46ID: 11548960

Thanks Cerf, I appreciate it!  :D

 

by: CerfPosted on 2004-07-14 at 07:17:02ID: 11549206

Any time.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...