Define SIMULATION_WAITMS_VALUE = 1
'---------------------------------------------------------------
'DEFININTIONS
'---------------------------------------------------------------
Define CONF_WORD = 0x3f50 'Internal Oscillator'
Define CLOCK_FREQUENCY = 8
AllDigital
'--------------------------------------------------------------
'LCD SETUP
'--------------------------------------------------------------
Define LCD_LINES = 4
Define LCD_CHARS = 20
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4 'Data RB7 - RB4
Define LCD_RSREG = PORTB
Define LCD_RSBIT = 3
Define LCD_EREG = PORTB
Define LCD_EBIT = 2
Define LCD_RWREG = PORTB
Define LCD_RWBIT = 1
Define LCD_READ_BUSY_FLAG = 1
'NOTE RB0 IS USED FOR INTERUPT!!!
Define LCD_COMMANDUS = 5000 'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 100 'delay after LCDOUT, default value is 100
Define LCD_INITMS = 20
'--------------------------------------------------
'variables
'----------------------------------------------------
Symbol encodera = PORTA.0
Symbol encoderb = PORTA.1
Dim init_freg As Byte 'used to set the initial frequency to band centre
Dim freq_step As Byte 'used to set the tuning step 1khz/10khz etc
Dim init_anlg As Byte
Dim anlg As Byte
Dim init_digi_mhz As Byte
Dim init_digi_khz As Byte
Dim init_digi_hz As Byte
Dim i As Byte
Dim intrcnt As Byte 'number of times interupt is triggered
Dim direction As Bit 'which direction the encoder is turning.
startup:
'------------------------------------------------------
'Clear the LCD and give everyting time to initialise
'------------------------------------------------------
Lcdinit 'LcdCurBlink
Lcdcmdout LcdClear
WaitMs 10
'---------------------------------------------------------------------
'Define the analoug display
'---------------------------------------------------------------------
Lcddefchar 0, %00000, %00000, %00000, %11111, %11111, %00000, %00000, %00000
Lcddefchar 1, %11111, %11111, %11111, %11111, %11111, %11111, %11111, %11111
'--------------------------------------------------------
'Welcome message to LCD
'--------------------------------------------------------
Lcdcmdout LcdLine1Pos(4)
Lcdout "DIGITAL VFO"
Lcdcmdout LcdLine2Pos(7)
Lcdout "by M0TVU"
Lcdcmdout LcdLine4Pos(4)
Lcdout "Version 1.01"
WaitMs 1000 '1000
Lcdcmdout LcdClear
'---------------------------------------------------
'Set initial Values
'----------------------------------------------------
init_anlg = 9
anlg = init_anlg
init_digi_mhz = 7
init_digi_khz = 100
init_digi_hz = 0
'---------------------------------------------------
'Set interupt values
'----------------------------------------------------
TRISB = 0x00
'adcon1 = 0x84
T1CON = 0x30 '00110000 - set the prescaler 1:8
T1CON.T1OSCEN = 1 'oscillator enabled
T1CON.TMR1CS = 0 'Timer 1 clock source 0= internal clock
T1CON.TMR1ON = 1 'Enable TIMER 1
TMR1H = 0x0b 'Values for high bit ? Why these values?
TMR1L = 0xdc 'Valur for low bit ?
INTCON.GIE = 1 'enable all unmasked interupts - unmasked?
INTCON.PEIE = 1 'enable all unmasked peripheral inteupts
PIE1.TMR1IE = 1 'Enable overflow
PIR1.TMR1IF = 0 'clear overflow
Enable 'what does this do?
'----------------------------------------------------------------
'MAIN BODY
'----------------------------------------------------------------
'Read initial value from encoder
'loop
'calculate frequency from encoder variable
'some code displaying the frequency looping around And sending data To the ad9850.
'End loop
'interupt - -> triggered by turning the encoder
'get new value from encoder
'update some variable To send back To freq
'Resume
loop:
'Give the main code something to do.
'Call digidsp(init_digi_mhz, init_digi_khz, init_digi_hz)
Call anlgdsp(anlg)
Goto loop
End
'----------------------------------------------------------------
'ON INTERRUPT
'----------------------------------------------------------------
On Interrupt
Save System
'interrupt triggers every 1/4 second approx so 4 times = 1 second.
'why aren't interupts disabled here?
PIR1.TMR1IF = 0 'clear the overflow
intrcnt = intrcnt + 1
If intrcnt = 4 Then 'interupted 4 times = 1 second?
intrcnt = 0
'this is where the interupt code would go.
direction = encodera Xor encoderb
If direction = 1 Then 'increment
anlg = anlg + 1
Else 'decrement
anlg = anlg - 1
Endif
Endif
TMR1H = 0x0b
TMR1L = 0xdc
Resume
'----------------------------------------------------------------
'Functions
'----------------------------------------------------------------
Function anlgdsp(arg1 As Byte) As Byte 'this should be a procedure!!
Lcdcmdout LcdLine3Home
Select Case arg1
Case 0
Lcdout 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 1
Lcdout 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 2
Lcdout 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 3
Lcdout 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 4
Lcdout 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 5
Lcdout 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 6
Lcdout 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 7
Lcdout 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 8
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 9
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 10
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
Case 11
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0
Case 12
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0
Case 13
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0
Case 14
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0
Case 15
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0
Case 16
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0
Case 17
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
Case 18
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0
Case 19
Lcdout 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
EndSelect
End Function
'----------------------------------------------------------------
'Procedures
'----------------------------------------------------------------
'---------------------------------------------------
'Set interupt values
'----------------------------------------------------
T1CON = 0x30 '00110000 - set the prescaler 1:8
T1CON.T1OSCEN = 1 'oscillator enabled
T1CON.TMR1CS = 0 'Timer 1 clock source 0= internal clock
T1CON.TMR1ON = 1 'Enable TIMER 1
''TRISB = 0x00 'if RB.0 is for intr then
TRISB = 0x01
'adcon1 = 0x84
'Timer1 is a 16 bit UP counter, so it would count from 0000h thru FFFFh
'as it rolls over to 0000h it will generate a TMR1 Interrupt
'To get the required interrupt interval we preload the Timer1 counter with
'a value.
'if the xtal is say 4MHz, this would mean the PIC internal cycle will be
'4MHZ/4 ie: 1MHZ == 1uSec
'we first divide this 1MHZ by 8 in the TMR1 prescaler to give 125KHz
'I prefer to use the Period rather than the Freq, so thats a 8uSec Period.
'If we want an TMR1 intr every 0.5Sec we need to calculate TMR1 Period as
'0.5sec/8uSec = 0.5/0.000008 = 62500uS, BUT as its a UP counter we must preload the
'TMR1 with its maximum possible count of 65536 - 62500 = 3036 decimal
'convert to Hex 0BDCh... So load TMR1H with 0Bh and TMR1L with DCh
'NOTE: you MUST reload this TMR1 count value every time you EXIT the Interrupt Subr
' as well as clearing the TMR1IF
TMR1H = 0x0b 'Values for high BYTE ? Why these values?
TMR1L = 0xdc 'Valur for low BYTE ?
INTCON.GIE = 1 'enable all unmasked interrupts - unmasked?
INTCON.PEIE = 1 'enable all unmasked peripheral interrupts
PIE1.TMR1IE = 1 'Enable overflow
PIR1.TMR1IF = 0 'clear overflow
Enable 'what does this do?
'BASIC should Enable the required Interrupts
'I prefer to control the Interrupts individually, as above.
'----------------------------------------------------------------
Define SIMULATION_WAITMS_VALUE = 1
'---------------------------------------------------------------
'DEFININTIONS
'---------------------------------------------------------------
Define CONF_WORD = 0x3f50 'Internal Oscillator'
Define CLOCK_FREQUENCY = 8
AllDigital
'--------------------------------------------------------------
'LCD SETUP
'--------------------------------------------------------------
Define LCD_LINES = 4
Define LCD_CHARS = 20
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4 'Data RB7 - RB4
Define LCD_RSREG = PORTB
Define LCD_RSBIT = 3
Define LCD_EREG = PORTB
Define LCD_EBIT = 2
Define LCD_RWREG = PORTB
Define LCD_RWBIT = 1
Define LCD_READ_BUSY_FLAG = 1
'NOTE RB0 IS USED FOR INTERUPT!!!
Define LCD_COMMANDUS = 5000 'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 100 'delay after LCDOUT, default value is 100
Define LCD_INITMS = 20
'--------------------------------------------------
'variables
'----------------------------------------------------
Symbol encodera = PORTA.0
Symbol encoderb = PORTA.1
Dim bandwidth_upper As Byte
Dim bandwidth_lower As Byte
Dim freq_step As Byte 'used to set the tuning step 1khz/10khz etc
Dim init_anlg As Byte
Dim anlg As Byte
Dim init_digi_mhz As Byte
Dim init_digi_khz As Byte
Dim init_digi_hz As Byte
Dim intrcnt As Byte 'number of times interupt is triggered
Dim direction As Bit 'which direction the encoder is turning.
startup:
'------------------------------------------------------
'Clear the LCD and give everyting time to initialise
'------------------------------------------------------
Lcdinit 'LcdCurBlink
Lcdcmdout LcdClear
WaitMs 10
'---------------------------------------------------------------------
'Define the analoug display
'---------------------------------------------------------------------
Lcddefchar 0, %00000, %00000, %00000, %11111, %11111, %00000, %00000, %00000
Lcddefchar 1, %11111, %11111, %11111, %11111, %11111, %11111, %11111, %11111
Lcddefchar 2, %10000, %10000, %10000, %11111, %11111, %10000, %10000, %10000
Lcddefchar 3, %00001, %00001, %00001, %11111, %11111, %00001, %00001, %00001
'--------------------------------------------------------
'Welcome message to LCD
'--------------------------------------------------------
Lcdcmdout LcdLine1Pos(4)
Lcdout "DIGITAL VFO"
Lcdcmdout LcdLine2Pos(7)
Lcdout "by M0TVU"
Lcdcmdout LcdLine4Pos(4)
Lcdout "Version 1.01"
WaitMs 1000 '1000
Lcdcmdout LcdClear
'---------------------------------------------------
'Set initial Values
'----------------------------------------------------
bandwidth_upper = 200
bandwidth_lower = 0
freq_step = 10
init_anlg = 9
anlg = init_anlg
init_digi_mhz = 7
init_digi_khz = 100
init_digi_hz = 0
'---------------------------------------------------
'Set interupt values
'----------------------------------------------------
TRISB = 0x00
'adcon1 = 0x84
'T1CON = 0x30 '00110000 - set the prescaler 1:8
'T1CON.T1OSCEN = 1 'oscillator enabled
'T1CON.TMR1CS = 0 'Timer 1 clock source 0= internal clock
'T1CON.TMR1ON = 1 'Enable TIMER 1
'TMR1H = 0x0b 'Values for high bit ? Why these values?
'TMR1L = 0xdc 'Valur for low bit ?
INTCON.GIE = 1 'enable all unmasked interupts - unmasked?
INTCON.PEIE = 1 'enable all unmasked peripheral inteupts
INTCON.INTE = 1 'external interrupt on RB0.
PIE1.TMR1IE = 1 'Enable overflow
PIR1.TMR1IF = 0 'clear overflow
Enable 'what does this do?
'----------------------------------------------------------------
'MAIN BODY
'----------------------------------------------------------------
'Read initial value from encoder
'loop
'calculate frequency from encoder variable
'some code displaying the frequency looping around And sending data To the ad9850.
'End loop
'interupt - -> triggered by turning the encoder
'get new value from encoder
'update some variable To send back To freq
'Resume
loop:
'Give the main code something to do.
'Call digidsp(init_digi_mhz, init_digi_khz, init_digi_hz)
Call anlgdsp(anlg)
Goto loop
End
'----------------------------------------------------------------
'ON INTERRUPT
'----------------------------------------------------------------
On Interrupt
Save System
'interrupt triggers every 1/4 second approx so 4 times = 1 second.
'why aren't interupts disabled here?
PIR1.TMR1IF = 0 'clear the overflow
intrcnt = intrcnt + 1
'If intrcnt = 4 Then 'interupted 4 times = 1 second?
'intrcnt = 0
'this is where the interupt code would go.
direction = encodera Xor encoderb
If direction = 1 Then 'increment
anlg = anlg + 1
Else 'decrement
anlg = anlg - 1
Endif
'Endif
TMR1H = 0x0b
TMR1L = 0xdc
Resume
'----------------------------------------------------------------
'Functions
'----------------------------------------------------------------
Function anlgdsp(arg1 As Byte) As Byte 'this should be a procedure!!
Lcdcmdout LcdLine3Home
Select Case arg1
Case 0
Lcdout 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 1
Lcdout 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 2
Lcdout 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 3
Lcdout 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 4
Lcdout 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 5
Lcdout 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 6
Lcdout 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 7
Lcdout 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 8
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 9
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 10
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 11
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3
Case 12
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3
Case 13
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 3
Case 14
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3
Case 15
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3
Case 16
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 3
Case 17
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3
Case 18
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3
Case 19
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
EndSelect
End Function
'----------------------------------------------------------------
'Procedures
'----------------------------------------------------------------
Aha! - After reading the data sheets I can see this INTCON.INTE = 1. This triggers the interrupt but now it just keeps triggering. Which flag must I clear in the interrupt routine to stop this.
INTCON.GIE = 1 'enable all unmasked GENERAL interrupts - unmasked= enabled
INTCON.PEIE = 1 'enable all unmasked PERIPHERAL interrupts
up = 1
dwn = 20
loop:
Call anlgdsp(anlg)
Goto loop
End
Function anlgdsp(arg1 As Byte) As Byte 'this should be a procedure!!
If dir = 0 Then
Lcdcmdout LcdLine3Pos(up)
Lcdout "-", 0x7e
up = up + 1
If up > 19 Then
up = 1
dir = 1
dwn = 20
Endif
Endif
If dir = 1 Then
Lcdcmdout LcdLine3Pos(dwn)
Lcdout 0x7f, " "
dwn = dwn - 1
If dwn < 1 Then
dwn = 1
dir = 0
up = 1
Endif
Endif
End Function
Define SIMULATION_WAITMS_VALUE = 1
'---------------------------------------------------------------
'DEFININTIONS
'---------------------------------------------------------------
Define CONF_WORD = 0x3f50 'Internal Oscillator'
Define CLOCK_FREQUENCY = 8
AllDigital
'--------------------------------------------------------------
'LCD SETUP
'--------------------------------------------------------------
Define LCD_LINES = 4
Define LCD_CHARS = 20
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4 'Data RB7 - RB4
Define LCD_RSREG = PORTB
Define LCD_RSBIT = 3
Define LCD_EREG = PORTB
Define LCD_EBIT = 2
Define LCD_RWREG = PORTB
Define LCD_RWBIT = 1
Define LCD_READ_BUSY_FLAG = 1
'NOTE RB0 IS USED FOR INTERUPT!!!
Define LCD_COMMANDUS = 5000 'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 100 'delay after LCDOUT, default value is 100
Define LCD_INITMS = 20
'--------------------------------------------------
'variables
'----------------------------------------------------
Symbol encodera = PORTA.0
Symbol encoderb = PORTA.1
Dim bandwidth_upper As Byte
Dim bandwidth_lower As Byte
Dim freq_step As Byte 'used to set the tuning step 1khz/10khz etc
Dim init_anlg As Byte
Dim anlg As Byte
Dim init_digi_mhz As Byte
Dim init_digi_khz As Byte
Dim init_digi_hz As Byte
Dim digi_mhz As Byte
Dim digi_khz As Byte
Dim digi_hz As Byte
Dim intrcnt As Byte 'number of times interupt is triggered
Dim direction As Bit 'which direction the encoder is turning.
startup:
'------------------------------------------------------
'Clear the LCD and give everyting time to initialise
'------------------------------------------------------
Lcdinit 'LcdCurBlink
Lcdcmdout LcdClear
WaitMs 10
'---------------------------------------------------------------------
'Define the analoug display
'---------------------------------------------------------------------
Lcddefchar 0, %00000, %00000, %00000, %11111, %11111, %00000, %00000, %00000
Lcddefchar 1, %11111, %11111, %11111, %11111, %11111, %11111, %11111, %11111
Lcddefchar 2, %10000, %10000, %10000, %11111, %11111, %10000, %10000, %10000
Lcddefchar 3, %00001, %00001, %00001, %11111, %11111, %00001, %00001, %00001
'--------------------------------------------------------
'Welcome message to LCD
'--------------------------------------------------------
Lcdcmdout LcdLine1Pos(5)
Lcdout "DIGITAL VFO"
Lcdcmdout LcdLine2Pos(7)
Lcdout "by M0TVU"
Lcdcmdout LcdLine4Pos(4)
Lcdout "Version 1.01"
WaitMs 1000 '1000
Lcdcmdout LcdClear
'---------------------------------------------------
'Set initial Values
'----------------------------------------------------
bandwidth_upper = 200
bandwidth_lower = 0
freq_step = 10
init_anlg = 9
anlg = init_anlg
init_digi_mhz = 7
init_digi_khz = 100
init_digi_hz = 0
digi_mhz = init_digi_mhz
digi_khz = init_digi_khz
digi_hz = init_digi_hz
'---------------------------------------------------
'Set interupt values
'----------------------------------------------------
TRISB = 0x00
'adcon1 = 0x84
'T1CON = 0x30 '00110000 - set the prescaler 1:8
'T1CON.T1OSCEN = 1 'oscillator enabled
'T1CON.TMR1CS = 0 'Timer 1 clock source 0= internal clock
'T1CON.TMR1ON = 1 'Enable TIMER 1
'TMR1H = 0xff 'Values for high bit ? Why these values?
'TMR1L = 0xfa 'Valur for low bit ?
INTCON.GIE = 1 'enable all unmasked interupts - unmasked?
INTCON.PEIE = 1 'enable all unmasked peripheral inteupts
INTCON.INTE = 1 'external interrupt on RB0.
'PIE1.TMR1IE = 1 'Enable overflow
'PIR1.TMR1IF = 0 'clear overflow
Enable 'what does this do?
'----------------------------------------------------------------
'MAIN BODY
'----------------------------------------------------------------
loop:
'Give the main code something to do.
Call digi_disp(digi_mhz, digi_khz, digi_hz)
Call anlg_disp(anlg)
Goto loop
End
'----------------------------------------------------------------
'ON INTERRUPT
'----------------------------------------------------------------
On Interrupt
Save System
'interrupt triggers every 1/4 second approx so 4 times = 1 second.
'why aren't interupts disabled here?
PIR1.TMR1IF = 0 'clear the overflow
INTCON.INTF = 0 'clear interrupt on RB0.
intrcnt = intrcnt + 1
'If intrcnt = 2 Then 'interupted 4 times = 1 second?
'intrcnt = 0
'this is where the interupt code would go.
direction = encodera Xor encoderb
If direction = 1 Then 'increment
If freq_step = 10 Then
digi_khz = digi_khz + 10
Endif
If freq_step = 1 Then
digi_hz = digi_hz + 1
Endif
anlg = anlg + 1
Else 'decrement
If freq_step = 10 Then
digi_khz = digi_khz - 10
Endif
If freq_step = 1 Then
digi_hz = digi_hz - 1
Endif
anlg = anlg - 1
Endif
'Endif
'TMR1H = 0xff
'TMR1L = 0xfa
Resume
'----------------------------------------------------------------
'Functions
'----------------------------------------------------------------
Function anlg_disp(arg1 As Byte) As Byte 'this should be a procedure!!
Lcdcmdout LcdLine3Home
Select Case arg1
Case 0
Lcdout 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 1
Lcdout 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 2
Lcdout 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 3
Lcdout 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 4
Lcdout 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 5
Lcdout 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 6
Lcdout 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 7
Lcdout 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 8
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 9
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 10
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3
Case 11
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3
Case 12
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3
Case 13
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 3
Case 14
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3
Case 15
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3
Case 16
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 3
Case 17
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3
Case 18
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3
Case 19
Lcdout 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
EndSelect
End Function
'----------------------------------------------------------------
'Procedures
'----------------------------------------------------------------
Proc digi_disp(arg1 As Byte, arg2 As Byte, arg3 As Byte,)
Lcdcmdout LcdLine1Pos(6)
Lcdout #arg1, "."
Lcdcmdout LcdLine1Pos(8)
Lcdout #arg2, "."
Lcdcmdout LcdLine1Pos(12)
Lcdout #arg3
End Proc
It's not really about the finished product more the HOW DO YOU DO THAT
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?