steve langner
Member
Couple of strange things occur with this code which I hope someone can explain and, hopefully, illustrate a better way of configuring the PIC 16F886 to flash a LED at a variable rate.
First, why do two config words appear in the PIC simulator at the beginning of the code (this is of course shown in the simulator config bits)
Second, Despite the fact that all pins are set digital (AllDigital statement), the Led in the actual hardware flashes quite happily and the flash rate is controllable with the pot as though the input is analog and linear? The simulator, however, shows the input, as one might expect, as digital.
First, why do two config words appear in the PIC simulator at the beginning of the code (this is of course shown in the simulator config bits)
Second, Despite the fact that all pins are set digital (AllDigital statement), the Led in the actual hardware flashes quite happily and the flash rate is controllable with the pot as though the input is analog and linear? The simulator, however, shows the input, as one might expect, as digital.
Code:
'PIC 16F886 variable flash rate
Define CONFIG = 0x2074
Define CONFIG2 = 0x3eff
Define CLOCK_FREQUENCY = 4
'Define SIMULATION_WAITMS_VALUE = 1 'used for simulation only
TRISA = %00000000
TRISB = %00100000 ' AN13
TRISC = %00000000
AllDigital
PORTA = 0 'to start
PORTB = 0 'to start
PORTC = 0 'to start
Dim pot As Word
main:
Adcin 13, pot
pot = pot / 2 'limits slowest flash-rate to 510 mSecs
RC3 = 1
WaitMs 10
RC3 = 0
WaitMs pot
Goto main
End
Last edited by a moderator: