Dear sirs, the following program was compiled and writing on a 16F84A, this work fine. Latter, before some changes in configuration I compiled and writing
on the pic 16F628 and work bad, don't stop in any button, can you help me. please!
#chip 16F628A, 4
#config XT_OSC, WDT_OFF, LVP_OFF, MCLRE_ON, BODEN_OFF
adoff
dim cicles as byte
dim steps as byte
dim counter as byte
dir porta b'00000111' 'pins 0-2 config. as input, rest as output
dir portb b'00000000' 'portb all pins as output (7 segm. digit)
porta = b'00000111'
portb = b'00000000' 'portb off
#define DisplayportA Portb
#define boton1 porta.0
#define boton2 porta.1
#define boton3 porta.2
#define der porta.3
#define izq porta.4 'this output is an open colector pin!!! require pullup resistor of
counter = 0 '4700 ohms to VCC and direct conection to the base of T1!!!
main:
if counter < 9 then
if boton1 low then counter = counter + 1 ' increase wash time
wait 100 ms
end if
DisplayValue 1, counter
if counter > 0 then
if boton2 low then counter = counter - 1 ' decrease wash time
wait 100 ms
end if
DisplayValue 1, counter
If boton3 low Then goTo wash ' stop wash with reset button
wait 100 ms
GoTo main
wash:
end
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Have you defined the value of the constant low? GCBASIC uses on and off, not high and low. If you add this line somewhere, it should work:
#define low off
I don't know why the program worked on the 16F84A! I did make a few changes to the IF code in GCBASIC a while ago, and that may have made GCBASIC change its behaviour.
Also you don't need the ADOff command any more. Newer versions of GCBASIC (since May) will automatically add code to turn off the A/D and comparator at the start of the program when needed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear sirs, the following program was compiled and writing on a 16F84A, this work fine. Latter, before some changes in configuration I compiled and writing
on the pic 16F628 and work bad, don't stop in any button, can you help me. please!
#chip 16F628A, 4
#config XT_OSC, WDT_OFF, LVP_OFF, MCLRE_ON, BODEN_OFF
adoff
dim cicles as byte
dim steps as byte
dim counter as byte
dir porta b'00000111' 'pins 0-2 config. as input, rest as output
dir portb b'00000000' 'portb all pins as output (7 segm. digit)
porta = b'00000111'
portb = b'00000000' 'portb off
#define DisplayportA Portb
#define boton1 porta.0
#define boton2 porta.1
#define boton3 porta.2
#define der porta.3
#define izq porta.4 'this output is an open colector pin!!! require pullup resistor of
counter = 0 '4700 ohms to VCC and direct conection to the base of T1!!!
main:
if counter < 9 then
if boton1 low then counter = counter + 1 ' increase wash time
wait 100 ms
end if
DisplayValue 1, counter
if counter > 0 then
if boton2 low then counter = counter - 1 ' decrease wash time
wait 100 ms
end if
DisplayValue 1, counter
If boton3 low Then goTo wash ' stop wash with reset button
wait 100 ms
GoTo main
wash:
end
Have you defined the value of the constant low? GCBASIC uses on and off, not high and low. If you add this line somewhere, it should work:
#define low off
I don't know why the program worked on the 16F84A! I did make a few changes to the IF code in GCBASIC a while ago, and that may have made GCBASIC change its behaviour.
Also you don't need the ADOff command any more. Newer versions of GCBASIC (since May) will automatically add code to turn off the A/D and comparator at the start of the program when needed.
OK! Thanks again, I'll add the line to define low and try again and hope this result, very truly yours