President Alan VK6ZWZ Acting Sec. Don VK6HK Vice President Terry VK6ZLT Treasurer Ces VK6AO

Similar documents
Lecture (04) PIC16F84A (3)

D:\PICstuff\PartCounter\PartCounter.asm

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

Performance & Applications

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

Assembly Language Instructions

PIC 16F84A programming (II)

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

Divide and Conquer Programming for Engineers Winter Andreas Rau, Saarland University

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */

Application Note - PIC Source Code v1.1.doc

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

CENG-336 Introduction to Embedded Systems Development. Timers

Chapter 13. PIC Family Microcontroller

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours

Flow Charts and Assembler Programs

Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh

movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

Week1. EEE305 Microcontroller Key Points

ECE Test #1: Name

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

SOLUTIONS!! DO NOT DISTRIBUTE!!

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

Instuction set

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

EEE111A/B Microprocessors

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics:

Chapter 5 Sections 1 6 Dr. Iyad Jafar

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

A Better Mouse Trap. Consumer Appliance, Widget, Gadget APPLICATION OPERATION: Ontario, Canada

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

Here is a sample of the Hellschrieber sent by this project: Following is the PIC MPASM Source Code for Version 0.03 of the Beacon:

Embedded System Design

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Chapter 3: Further Microcontrollers

S w e d i s h c r. w e e b l y. c o m j a l i l a h m e l i v e. c o m Page 1

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

Learning Objectives:

Chapter 11: Interrupt On Change

CONNECT TO THE PIC. A Simple Development Board

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

Binary Outputs and Timing

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling

ECE 354 Introduction to Lab 2. February 23 rd, 2003

PIC Discussion. By Eng. Tamar Jomaa

Section 31. Instruction Set

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER

M PIC16F84A. 18-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller. High Performance RISC CPU Features: Pin Diagrams. Peripheral Features:

ME 515 Mechatronics. A microprocessor

GUIDE TO USE OF PIC 16F690 EEProm. The 16F690 PIC has a 256 byte EEProm (mapped to 0x x21FF).

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

16.317: Microprocessor-Based Systems I Spring 2012

ME 6405 Introduction to Mechatronics

Arithmetic,logic Instruction and Programs

16.317: Microprocessor-Based Systems I Summer 2012

Section 13. Timer0 HIGHLIGHTS. Timer0. This section of the manual contains the following major topics:

Laboratory Exercise 5 - Analog to Digital Conversion

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

These 3 registers contain enable, priority,

PIC16F84A 7.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

16.317: Microprocessor Systems Design I Fall 2015

PIC16C84. 8-bit CMOS EEPROM Microcontroller PIC16C84. Pin Diagram. High Performance RISC CPU Features: CMOS Technology: Peripheral Features:

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011

ECE Homework #3

DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER

Model Answer Microcontrollers. MCQ Problems Total Q1 Q2

More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller

Appendix D: Source Codes. PDF created with pdffactory Pro trial version

Embedded Systems Programming and Architectures

DERTS Design Requirements (1): Microcontroller Architecture & Programming

Experiment 7:The USART

EXPERIMENT 4: Parallel Input/Output. Objectives Introduction to the Parallel Input/Output (I/O) Familiarization to Interfacing

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers

/ 28 HLL assembly Q4: Conditional instructions / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

Interfacing PIC Microcontrollers to Peripherial Devices

PTK8756B 8 Bit Micro-controller Data Sheet

Done 1 NVB THF TLF T/R POL 1SHOT. Figure 1: Status register

Section 4. Architecture

Beacon Keyers Using PIC s. Dave Powis, DL/G4HUP

PICDEM-1 USER S GUIDE

PIC16C432 OTP 8-Bit CMOS MCU with LIN bus Transceiver

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

16.317: Microprocessor Systems Design I Spring 2015

PIC16F8X. 8-Bit CMOS Flash/EEPROM Microcontrollers PIC16F8X PIC16CR8X. Pin Diagram. Devices Included in this Data Sheet:

Micro II and Embedded Systems

Transcription:

The West Australian VHF Group Bulletin JANUARY 2002 THE WEST AUSTRALIAN VHF GROUP (INC) PO BOX 189 APPLECROSS e-mail for editor to: pi@multiline.com.au President Alan VK6ZWZ Acting Sec. Don VK6HK Vice President Terry VK6ZLT Treasurer Ces VK6AO Activities Materials Publicity Librarian Al VK6ZAY Museum Rep Tom VK6ZAF Bulletin Editor Luigi VK6YEH Councillor Wally VK6KZ Councillor Terry VK6TRG NOV 12 VHF MICROWAVE NET JAN 14 VHF MICROWAVE NET 19 COMMITTEE MEETING 21 COMMITTEE MEETING 26 GENERAL MEETING 28 GENERAL MEETING FEB 11 VHF MICROWAVE NET MAR 11 VHF MICROWAVE NET 18 COMMITTEE MEETING 18 COMMITTEE MEETING 25 GENERAL MEETING 25 GENERAL MEETING APR 8 VHF MICROWAVE NET MAY 13 VHF MICROWAVE NET 15 COMMITTEE MEETING 20 COMMITTEE MEETING 22 ANNUAL GEN. MEETING 27 GENERAL MEETING 1

Editors Note: A new year has dawned and I trust you have all had a good Christmas and New Year. Several calls were received over the holiday season with some good activity on 6m. For those of you who missed it, Novembers meeting had a very interesting presentation by Al (VK6ZWZ). This consisted of a dish antenna made from a golfing umbrella capable of receiving 1269MHz and 2.4GHz. We will be looking at a future technical article on this. The technical article dominates this months bulletin so introductions need to be short. 73 s until the next bulletin. Technical Article: Remote Keyer with Fault Detection Software Continuing on our remote keyer project, the following is a listing of the software used to control the keyer. To assist those who may not have had experience in programming a PIC processor a description of how the software operates is included. The software assumes a 4MHz oscillator was used. As you can see it has been configured to operate as a remote keyer for either a beacon or repeater application. This allows for some flexibility in its use. As with any micro-controller project, there is a limit as to the amount of flexibility verses code. It is believed that this code allows sufficient flexibility without adding code, which may prove redundant in many applications. Before discussing the code itself we will look at the predefined parameters to see where changes may be made. BEACON_OP DOT DASH BIT_DELAY CHAR_DELAY STATE0/1 TX_INTVL_LOW TX_INTVL_HIGH TIMER_DLY CHAN_x_BIT TONE_BIT TX_EN_BIT MORSE_x If this is define the software acts in beacon mode ie. the transmitter is assumed to be continuously operating and a tone is generated for a time interval. The identifier is sent followed by a character depicting a fault if one exists. If this definition is commented out the software operates in repeater mode ie. There is silence until the predetermined time has expired. The transmitter is turned on by setting port A bit 1 HIGH and the identifier sent. Again, if a fault is detected the fault character is sent before the transmitter is keyed down. Defines the length of the dot tone symbol in milliseconds. Defines the length of the dash tone symbol in milliseconds. Defines the length of time between a dot or dash tone. This number must be different to the dot or dash delay. Defines the length of time between a morse character. This number must be different to the dot or dash delay. Defines operational states and should not be changed. Defines the low byte of the transmission interval in milliseconds. Defines the high byte of the transmission interval in milliseconds. A maximum interval of 65.535 seconds may be currently set. Defines the preset internal timer value. This coupled with the internal hardware divider gives the 1ms increments on which we have based the time. Defines the fault channel port bits. Defines the tone output port bit. Defines the transmitter enable output port bit. Defines the morse alphabet and numerals. Note the each character has a inter-character delay value appended to it. The software uses the following variables. opstate time_low time_high table_ptr morse_data Contains the current operational state Contains the low byte of the interval timer countdown value. Contains the high byte of the interval timer countdown value. These values can be expanded to more bytes to make the transmission interval longer. Is a counter used when stepping through the morse strings. Temporarily stores a morse delay value. 2

morse_dly W_TEMP STAT_TEMP tone_flag count Loaded with the delay required for a tone or space interval. Temporary storage for W register. Temporary storage for status register. When this is set to ON the tone output is toggling. General counter. The messages transmitted consists of a string of morse characters terminated by a 0. The station identifier is set first. Simply change the definitions for the identifier required. The remainder of the tables are status characters assigned to a fault channel. These status characters may be expanded to be short messages. Eg. curr_stat_a addwf dt PCL,F MORSE_S,MORSE,W,MORSE_R,WORD_DELAY,0 This can be used to transmit SWR for an SWR fault. The watchdog timer is enabled in case a software fault occurs. Ensure the watchdog is reset at regular intervals to ensure the software does not reset. The timer and I/O ports are initialized before the main routines are executed. When in state 0 the software is waiting for the timer interval to expire. This in checked inside the interrupt routine. Once expired the state is set to 1. With the state set to 1 the station identifier followed by the fault status, if applicable, is sent. The timer interrupt routine performs the following functions. The interval timer is decremented. When this reaches 0 it changes the state to 1. When in state 1 it checks the delay register to see if a delay was set. The delay is consequently decremented. The tone flag is then tested to see if the tone bit needs to be toggled. ; Name: radiomon.asm ; Version: 1.00 ; Author: L.Iemi (VK6YEH) ; Purpose:These routines control the radio monitor unit ; Release Date: 20th January 2002 ; Modification History: 20/01/2002 Initial release include p16f84.inc ; definitions #define BEACON_OP 0 ; define this if used in a beacon ; otherwise comment it out for repeater #define DOT 0x55 ; number of timer cycles for a morse dot #define DASH 0xff ; number of timer cycles for a morse dash #define BIT_DELAY 0x56 ; bit space space #define CHAR_DELAY 0xfe ; character space #define STATE_0 0 ; wait for tx interval #define STATE_1 0x01 ; send the station ID ; transmission interval 5 seconds #define TX_INTVL_LOW 0x88 ; transmission interval (ms) low #define TX_INTVL_HIGH 0x13 ; transmission interval (ms) high 3

#define TIMER_DLY 0x83 ; timer delay (125) along with prescaler of 4 ; gives 1ms delay #define CHAN_A_BIT 0 ; Channel A input #define CHAN_B_BIT 1 ; Channel B input #define CHAN_C_BIT 2 ; Channel C input #define CHAN_D_BIT 3 ; Channel D input #define CHAN_E_BIT 4 ; Channel E input #define CHAN_F_BIT 5 ; Channel F input #define CHAN_G_BIT 6 ; Channel G input #define CHAN_H_BIT 7 ; Channel H input #define TONE_BIT 0 ; Tone output #define TX_EN_BIT 1 ; Tx enable output #define OFF 0 ; off #define ON 1 ; on ; morse code alphabet #define MORSE_A #define MORSE_B #define MORSE_C #define MORSE_D #define MORSE_E #define MORSE_F #define MORSE_G #define MORSE_H #define MORSE_I #define MORSE_J #define MORSE_K #define MORSE_L #define MORSE_M #define MORSE_N #define MORSE_O #define MORSE_P #define MORSE_Q #define MORSE_R #define MORSE_S #define MORSE_T #define MORSE_U #define MORSE_V #define MORSE_W #define MORSE_X #define MORSE_Y #define MORSE_Z #define MORSE_1 #define MORSE_2 #define MORSE_3 #define MORSE_4 #define MORSE_5 #define MORSE_6 #define MORSE_7 #define MORSE_8 #define MORSE_9 #define MORSE_0 DOT,DASH,CHAR_DELAY DASH,DOT,DOT,DOT,CHAR_DELAY DASH,DOT,DASH,DOT,CHAR_DELAY DASH,DOT,DOT,CHAR_DELAY DOT,CHAR_DELAY DOT,DOT,DASH,DOT,CHAR_DELAY DASH,DASH,DOT,CHAR_DELAY DOT,DOT,DOT,DOT,CHAR_DELAY DOT,DOT,CHAR_DELAY DOT,DASH,DASH,DASH,CHAR_DELAY DASH,DOT,DASH,CHAR_DELAY DOT,DASH,DOT,DOT,CHAR_DELAY DASH,DASH,CHAR_DELAY DASH,DOT,CHAR_DELAY DASH,DASH,DASH,CHAR_DELAY DOT,DASH,DASH,DOT,CHAR_DELAY DASH,DASH,DOT,DASH,CHAR_DELAY DOT,DASH,DOT,CHAR_DELAY DOT,DOT,DOT,CHAR_DELAY DASH,CHAR_DELAY DOT,DOT,DASH,CHAR_DELAY DOT,DOT,DOT,DASH,CHAR_DELAY DOT,DASH,DASH,CHAR_DELAY DASH,DOT,DOT,DASH,CHAR_DELAY DASH,DOT,DASH,DASH,CHAR_DELAY DASH,DASH,DOT,DOT,CHAR_DELAY DOT,DASH,DASH,DASH,DASH,CHAR_DELAY DOT,DOT,DASH,DASH,DASH,CHAR_DELAY DOT,DOT,DOT,DASH,DASH,CHAR_DELAY DOT,DOT,DOT,DOT,DASH,CHAR_DELAY DOT,DOT,DOT,DOT,DOT,CHAR_DELAY DASH,DOT,DOT,DOT,DOT,CHAR_DELAY DASH,DASH,DOT,DOT,DOT,CHAR_DELAY DASH,DASH,DASH,DOT,DOT,CHAR_DELAY DASH,DASH,DASH,DASH,DOT,CHAR_DELAY DASH,DASH,DASH,DASH,DASH,CHAR_DELAY ; equates 4

opstate equ 0x0D ; state of processing time_low equ 0x0E ; minute interval counter (low byte) time_high equ 0x0F ; minute interval counter (high byte) table_ptr equ 0x10 ; table pointer morse_data equ 0x11 ; holds morse delay value morse_dly equ 0x12 ; holds morse delay W_TEMP equ 0x13 ; temporary W stack STAT_TEMP equ 0x14 ; temporary status stack tone_flag equ 0x15 ; tone enable flag count equ 0x16 ; delay counter ; init interrupt vectors org 0 ;start address 0 goto start org goto 0x04 ; interrupt start address 0x04 timerint ; start of program org 0x08 ; station identifier - VK6YEH station_id dt MORSE_V,MORSE_K,MORSE_6,MORSE_Y,MORSE_E,MORSE_H,0 ; Fault channel identifier curr_stat_a dt MORSE_A,0 curr_stat_b dt MORSE_B,0 curr_stat_c dt MORSE_C,0 curr_stat_d dt MORSE_D,0 curr_stat_e dt MORSE_E,0 curr_stat_f dt MORSE_F,0 curr_stat_g dt MORSE_G,0 curr_stat_h dt MORSE_H,0 5

; Start of program start: clrf PORTA ; set port A outputs low clrf PORTB ; set all port B outputs low ; Delay by timer interrupt clrwdt ; clear watchdog bsf STATUS,RP0 ; select bank 1 movlw 0x1c ; set data direction of port A ; RA0 = output - tone output ; RA1 = output - transmitter enable ; RA2 = input ; RA3 = input ; RA4 = input movwf TRISA movlw 0xff ; set port B direction ; RB0 = input ; RB1 = input ; RB2 = input ; RB3 = input ; RB4 = input ; RB5 = input ; RB6 = input ; RB7 = input movwf TRISB movlw b'10000010' ; bit 7 - port b pullups disabled ; bit 6 - don't care ; bit 5 - internal clock ; bit 4 - don't care ; bit 3 - prescaler set to TMR0 ; bit 2,1,0 - divide by 4 movwf OPTION_REG bcf STATUS,RP0 ; select bank 0 movlw TIMER_DLY ; set timer delay movwf TMR0 ; set the delay clearing the prescaler as well bsf INTCON,T0IE ; enable timer overflow interrupt bcf INTCON,T0IF ; clear the interrupt flag main_start: bcf INTCON,GIE ; disable global interrupts clrf opstate ; clear the operational state movlw TX_INTVL_LOW movwf time_low movlw TX_INTVL_HIGH movwf time_high ; intialize message interval bsf INTCON,GIE ; enable global interrupts ifdef BEACON_OP movlw ON ; turn tone on 6

movwf tone_flag else clrf tone_flag ; turn tone off endif ; state 0 state0: movf opstate,w ; wait here until the timer has expired sublw STATE_0 btfss STATUS,Z goto state1 clrwdt ; clear watchdog goto state0 ; state 1 state1: movf opstate,w ; start sending the identifier sublw STATE_1 btfss STATUS,Z goto chk_a ifdef BEACON_OP clrf tone_flag ; turn tone off else bsf PORTA,TX_EN_BIT ; enable transmitter in repeater mode endif ; brief pause before message state1a: clrf movlw movwf movf call table_ptr; set to start of table HIGH station_id ; get station ID offset PCLATH table_ptr,w station_id andlw 0xff ; is data 0 terminator goto state1b goto state1a state1b: ; Check channel A - port B bit 0 chk_a: btfss PORTB,CHAN_A_BIT ; check channel A goto chk_b chk_aa: movlw movwf movf call HIGH curr_stat_a; get 'A' morse table PCLATH table_ptr,w curr_stat_a 7

goto chk_ab goto chk_aa chk_ab: ; Check channel B - port B bit 1 chk_b: btfss PORTB,CHAN_B_BIT ; check channel b goto chk_c chk_ba: movlw HIGH curr_stat_b ; get 'B' morse table call curr_stat_b goto chk_bb goto chk_ba chk_bb: ; Check channel C - port B bit 2 chk_c: btfss PORTB,CHAN_C_BIT ; check channel C goto chk_d chk_ca: movlw HIGH curr_stat_c; get 'C' morse table call curr_stat_c goto chk_cb goto chk_ca chk_cb: ; Check channel D - port B bit 3 8

chk_d: chk_da: btfss PORTB,CHAN_D_BIT ; check channel D goto chk_e movlw HIGH curr_stat_d ; get 'D' morse table call curr_stat_d goto chk_db goto chk_da chk_db: ; Check channel E - port B bit 4 chk_e: btfss PORTB,CHAN_E_BIT ; check channel E goto chk_f chk_ea: movlw HIGH curr_stat_e; get 'E' morse table call curr_stat_e goto chk_eb goto chk_ea chk_eb: ; Check channel F - port B bit 5 chk_f: btfss PORTB,CHAN_F_BIT ; check channel F goto chk_g chk_fa: movlw HIGH curr_stat_f ; get 'F' morse table call curr_stat_f goto chk_fb 9

incf goto table_ptr,f chk_fa chk_fb: ; Check channel G - port A bit 2 chk_g: btfss PORTA,CHAN_C_BIT ; check channel G goto chk_h chk_ga: movlw HIGH curr_stat_g ; get 'G' morse table call curr_stat_g goto chk_gb goto chk_ga chk_gb: ; Check channel H - port A bit 3 chk_h: btfss PORTA,CHAN_D_BIT ; check channel H goto key_down chk_ha: movlw HIGH curr_stat_h ; get 'H' morse table call curr_stat_h goto chk_hb goto chk_ha chk_hb: ; brief pause at end of message ; Key down key_down: ifndef BEACON_OP ; if operating in repeater mode bcf PORTA,TX_EN_BIT ; disable transmitter endif goto main_start ; do it again 10

; Send a word delay sendwordspace: movlw 0x03 movwf count ; set the number of delay increments sendwordspacea: movlw CHAR_DELAY movwf morse_dly call morsewait ; wait for delay to complete decfsz count,f ; decrement counter goto sendwordspacea return ; Send a morse bit txmorse: movf morse_data,w sublw DOT ; is it a DOT goto txmorse1 movf morse_data,w sublw DASH ; is it a DASH goto txmorse1 movf morse_data,w ; set other delay movwf morse_dly call morsewait ; wait for delay to complete return txmorse1: movlw ON ; turn on tone movwf tone_flag movf morse_data,w ; set tone delay movwf morse_dly call morsewait ; wait for tone to complete movlw OFF ; turn off tone movwf tone_flag movlw BIT_DELAY ; set bit delay movwf morse_dly call morsewait ; wait for it to complete txmorse2: return ; Morse delay morsewait: clrwdt ; reset watchdog movf morse_dly,w ; see if the delay has expired andlw 0FFH btfss STATUS,Z goto morsewait return ; Timer interrupt timerint: movwf W_TEMP ; save current W register setting 11

swapf STATUS,W movwf STAT_TEMP ; save current status register movlw TIMER_DLY ; set timer delay movwf TMR0 ; set the delay clearing the prescaler as well ; 1ms timer proc_0: movf opstate,w ; the timer has expired. Are we still in state 0 sublw STATE_0 ; see if in state 0 btfss STATUS,Z goto proc_1 decfsz time_low,f ; decrement timer low byte goto proc_1 movf time_high,w ; is the high byte 0 goto proc_0a decf time_high,f ; decrement timer high byte goto proc_1 proc_0a: movlw STATE_1 ; set next state movwf opstate proc_1: movf opstate,w ; are we in state 1 sublw STATE_1 btfss STATUS,Z goto proc_2 movf morse_dly,w ; see if the delay counter is already 0 andlw 0FFH goto proc_2 decf morse_dly,f ; decrement delay counter proc_2: movf tone_flag,w ; control the tone output sublw ON ; see if the tone is enabled btfss STATUS,Z goto proc_2a btfss PORTA,TONE_BIT ; is the tone bit high goto proc_2b proc_2a: bcf PORTA,TONE_BIT ; set tone bit LOW goto int_exit proc_2b: bsf PORTA,TONE_BIT ; set tone bit HIGH goto int_exit int_exit bcf INTCON,T0IF ; clear the interrupt flag swapf STAT_TEMP,W ; restore status register movwf STATUS swapf W_TEMP,F swapf W_TEMP,W retfie end ; end of program 12