I wrote program for PIC16F84A, it is working but something tells me that it can be done by easy way.
I appreciate your any advices that help to improve my program. Boring part is 95uSec delay when
PIC starts to work before recognizing Start button.
Due to my program PIC doing total delays equal 744 milliseconds per Sec so it will be great if PIC could do something different than staying in delays short periods of time such as 5 microseconds.
I check serial set commands but they have duration more than 2 milliseconds so it does not works.
May be someone has an ideas for that for example if PIC will be able to play music at time when
PIC has to do delays in different ways.
'* Notes : Target processor PIC16F84A *
'* : Driver *
'************************************************* ***************
'
DEFINE OSC 20
define __CONFIG _CP_OFF&_WDT_OFF&_BODEN_OFF&_PWRTE_ON
TRISA = 255 ' Set PORTA to all input
TRISB = %00000000 ' Set all of PORTB to outputs
CLEAR ' Clear all variables to 0
youvar var bit
myvar var bit
'hisvar var bit
hervar var bit
wevar var bit
pot1 con %00000100
pot2 con %00010101
pot3 con %00100110
pot4 con %00110111
pot5 con %01001000
pot6 con %01011001
pot7 con %01101010
pot8 con %01111011
pot9 con %10001100
pot10 con %10011101
pot11 con %10101110
pot12 con %10111111
pot13 con %11001110
pot14 con %11011101
pot15 con %11101100
pot16 con %11111011
pot17 con %11101010
pot18 con %11011001
pot19 con %11001000
pot20 con %10110111
pot21 con %10100110
pot22 con %10010101
pot23 con %10000100
pot24 con %01110011
pot25 con %01100010
pot26 con %01010001
pot27 con %01000000
pot28 con %00110001
pot29 con %00100010
pot30 con %00010011
rot1 con %11110100
rot2 con %11100101
rot3 con %11010110
rot4 con %11000111
rot5 con %10111000
rot6 con %10101001
rot7 con %10011010
rot8 con %10001011
rot9 con %01111100
rot10 con %01101101
rot11 con %01011110
rot12 con %01001111
rot13 con %00111110
rot14 con %00101101
rot15 con %00011100
rot16 con %00001011
rot17 con %00011010
rot18 con %00101001
rot19 con %00111000
rot20 con %01000111
rot21 con %01010110
rot22 con %01100101
rot23 con %01110100
rot24 con %10000011
rot25 con %10010010
rot26 con %10100001
rot27 con %10110000
rot28 con %11000001
rot29 con %11010010
rot30 con %11100011
sot1 con %10001000
sot2 con %11001100
sot3 con %01000100
sot4 con %01100110
sot5 con %00100010
sot6 con %00110011
sot7 con %00010001
sot8 con %10011001
Main:
PORTB = %00000000
myvar = PORTA.0 'Run = 1 Stop = 0
youvar = PORTA.1 'Direct rotation = 0 Reverse = 1
'hisvar = PORTA.2 '4 Hz two generators 1-2-3-4 5-6-7-8
hervar = PORTA.3 '2 HZ two generators 1-2-3-4 5-6-7-8
wevar = PORTA.4 ' ! Hz Two Generators 1-2-3-4 5-6-7-8
if wevar = 1 then Gen1
if hervar = 1 then Gen2
if hisvar = 0 then sRun1
if hisvar = 1 then sRun2
goto main
Gen1:
PORTB =sot1
PAUSE 250
PORTB =sot2
PAUSE 250
PORTB =sot3
PAUSE 250
PORTB =sot4
PAUSE 250
PORTB =sot5
PAUSE 250
PORTB =sot6
PAUSE 250
PORTB =sot7
PAUSE 250
PORTB =sot8
PAUSE 250
myvar = PORTA.0
If myvar = 0 Then main
goto gen1
Gen2:
PORTB =sot1
PAUSE 125
PORTB =sot2
PAUSE 125
PORTB =sot3
PAUSE 125
PORTB =sot4
PAUSE 125
PORTB =sot5
PAUSE 125
PORTB =sot6
PAUSE 125
PORTB =sot7
PAUSE 125
PORTB =sot8
PAUSE 125
myvar = PORTA.0
IF myvar = 0 then main
Goto Gen2
sRun1:
myvar = PORTA.0 'Run = 1 Stop = 0
youvar = PORTA.1
if myvar = 0 then Main
if youvar = 0 then RotateL
goto main
sRun2:
myvar = PORTA.0 'Run = 1 Stop = 0
youvar = PORTA.1
if myvar = 0 then Main
if youvar = 1 then RotateR
goto main
RotateL:
PORTB = pot1
PAUSEUS 5
PORTB = pot2
PAUSEUS 5
PORTB = pot3
PAUSEUS 5
PORTB = pot4
PAUSEUS 5
PORTB = pot5
PAUSEUS 5
PORTB = pot6
PAUSEUS 5
PORTB = pot7
PAUSEUS 5
PORTB = pot8
PAUSEUS 5
PORTB = pot9
PAUSEUS 5
PORTB = pot10
PAUSEUS 5
PORTB = pot11
PAUSEUS 5
PORTB = pot12
PAUSEUS 5
PORTB = pot13
PAUSEUS 5
PORTB = pot14
PAUSEUS 5
PORTB = pot15
PAUSEUS 5
PORTB = pot16
PAUSEUS 5
PORTB = pot17
PAUSEUS 5
PORTB = pot18
PAUSEUS 5
PORTB = pot19
PAUSEUS 5
PORTB = pot20
PAUSEUS 5
PORTB = pot21
PAUSEUS 5
PORTB = pot22
PAUSEUS 5
PORTB = pot23
PAUSEUS 5
PORTB = pot24
PAUSEUS 5
PORTB = pot25
PAUSEUS 5
PORTB = pot26
PAUSEUS 5
PORTB = pot27
PAUSEUS 5
PORTB = pot28
PAUSEUS 5
PORTB = pot29
PAUSEUS 5
PORTB = pot30
PAUSEUS 5
myvar = PORTA.0
if myvar = 0 then Main
GOTO RotateL
RotateR:
PORTB = rot1
PAUSEUS 5
PORTB = rot2
PAUSEUS 5
PORTB = rot3
PAUSEUS 5
PORTB = rot4
PAUSEUS 5
PORTB = rot5
PAUSEUS 5
PORTB = rot6
PAUSEUS 5
PORTB = rot7
PAUSEUS 5
PORTB = rot8
PAUSEUS 5
PORTB = rot9
PAUSEUS 5
PORTB = rot10
PAUSEUS 5
PORTB = rot11
PAUSEUS 5
PORTB = rot12
PAUSEUS 5
PORTB = rot13
PAUSEUS 5
PORTB = rot14
PAUSEUS 5
PORTB = rot15
PAUSEUS 5
PORTB = rot16
PAUSEUS 5
PORTB = rot17
PAUSEUS 5
PORTB = rot18
PAUSEUS 5
PORTB = rot19
PAUSEUS 5
PORTB = rot20
PAUSEUS 5
PORTB = rot21
PAUSEUS 5
PORTB = rot22
PAUSEUS 5
PORTB = rot23
PAUSEUS 5
PORTB = rot24
PAUSEUS 5
PORTB = rot25
PAUSEUS 5
PORTB = rot26
PAUSEUS 5
PORTB = rot27
PAUSEUS 5
PORTB = rot28
PAUSEUS 5
PORTB = rot29
PAUSEUS 5
PORTB = rot30
PAUSEUS 5
myvar = PORTA.0
if myvar = 0 then Main
GOTO RotateR
end
Bookmarks