Hi all!
I run into a strange (or I made some stupid error) problem. I hope some of you guys can give me a clue here.
First the circuit, 16F88, LCD (not yet involved), two LED’s and a few resistors. One LED at pin 18 another one at pin 3. The circuit will eventually control a stepper motor via an UNC5804 (pin 18 for direction and pin 3 pulse) the LED’s are temporary for test of the outputs.
Now the problem, PORTA.1 set high the LED lit OK but as soon as PORTA.4 goes high the first one goes low. ?
The code:
'************************************************* ***************
'* Name : STEP2.BAS *
'* Date : 2008-06-14 *
'* Version : 1.0 *
'* Notes : 16F88 - LCD moved to portb *
'************************************************* ***************
define OSC 8
OSCCON =%01110000 ' INTRC = 8MHz
TRISB = %00000000 ' PORTB = outputs
TRISA = %00000000 ' PORTA = outputs
CMCON = 7 ' Compar. = off
gosub MOVELCD
A var word ' A = word variabel
DI var PORTA.1 ' direction - pin 18
ST var PORTA.4 ' step - pin 3
DI = 1
pause 500
DI = 0
pause 500
ST = 1
pause 500
ST = 0
MAIN:
DI = 1
pause 500
for a = 0 to 200
ST = 1
pause 2
ST = 0
next a
DI = 0
pause 500
for a = 200 to 0 step -1
ST = 1
pause 2
ST = 0
next a
pause 1000
goto main
end
MOVELCD:
define LCD_DREG PORTB
define LCD_DBIT 0
define LCD_RSREG PORTB
define LCD_RSBIT 5
define LCD_EREG PORTB
define LCD_EBIT 4
define LCD_BITS 4
define LCD_LINES 2
Pause 800
return
Thanks!
Bookmarks