Hi All
programme loops correctly and displays the pot postions. When the 232 string is sent
the correct ascii value is displayed but the pot positions lock up. The RxTx lines are connected thru MAX232 chip. Please help as i can not see where i am going wrong. Thanks in advance.
;Chip Settings
chip 16F887,8
;Defines (Constants)
define LCD_IO 8
define LCD_RW PORTD.6
define LCD_Enable PORTD.7
define LCD_RS PORTD.5
define LCD_DATA_PORT PORTB
define CWrelay porta.1
define CCWRelay porta.2
define CWLED porta.3
define CCWLED porta.4
define USART_BAUD_RATE 9600
define USART_BLOCKING
;Variables
Dim potposition As integer
Dim WiperPosition As integer
Dim instring as integer
dim Count as integer
;Interrupt Handlers
On Interrupt UsartRx1ready Call getdata
InitUsart
'initusart
'#define POTposition Porta.0
Dir CWRelay Out
Dir CCWRelay Out
Dir CWLED Out
Dir CCWLED Out
Dir PORTA.0 In
Dir PORTA.5 In
'Switchs
Dir PORTD.0 In
Dir PORTD.1 In
Wait 100 mS
cls
potposition = 0
wiperposition = 0
'Main loop
Main:
if PORTD.1 = False then
set CWrelay on
else
set CWrelay off
end if
If PORTD.0 = False then
set CCWrelay on
else
set CCWrelay off
end if
if porte.0=false then
Set CCWLED on
else
Set CCWLED off
end if
if porte.1=false then
Set CWLED on
else
Set CWLED off
end if
Wiperposition = ReadAD10(AN4)
potposition = ReadAD10(AN0)
locate 1,0
print "Pot Pos : "
locate 1,12
print potposition
locate 2,0
print "Wiper Pos : "
locate 2,12
print Wiperposition
Wait 25 mS
goto Main
Sub getdata
Set CCWLED on
Wait 1 mS
instring=HSerReceive
locate 3,0
print instring
Wait 250 mS
Set CCWLED off
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All
programme loops correctly and displays the pot postions. When the 232 string is sent
the correct ascii value is displayed but the pot positions lock up. The RxTx lines are connected thru MAX232 chip. Please help as i can not see where i am going wrong. Thanks in advance.
;Chip Settings
chip 16F887,8
;Defines (Constants)
define LCD_IO 8
define LCD_RW PORTD.6
define LCD_Enable PORTD.7
define LCD_RS PORTD.5
define LCD_DATA_PORT PORTB
define CWrelay porta.1
define CCWRelay porta.2
define CWLED porta.3
define CCWLED porta.4
define USART_BAUD_RATE 9600
define USART_BLOCKING
;Variables
Dim potposition As integer
Dim WiperPosition As integer
Dim instring as integer
dim Count as integer
;Interrupt Handlers
On Interrupt UsartRx1ready Call getdata
InitUsart
'initusart
'#define POTposition Porta.0
Dir CWRelay Out
Dir CCWRelay Out
Dir CWLED Out
Dir CCWLED Out
Dir PORTA.0 In
Dir PORTA.5 In
'Switchs
Dir PORTD.0 In
Dir PORTD.1 In
Wait 100 mS
cls
potposition = 0
wiperposition = 0
'Main loop
Main:
if PORTD.1 = False then
set CWrelay on
else
set CWrelay off
end if
If PORTD.0 = False then
set CCWrelay on
else
set CCWrelay off
end if
if porte.0=false then
Set CCWLED on
else
Set CCWLED off
end if
if porte.1=false then
Set CWLED on
else
Set CWLED off
end if
Wiperposition = ReadAD10(AN4)
potposition = ReadAD10(AN0)
locate 1,0
print "Pot Pos : "
locate 1,12
print potposition
locate 2,0
print "Wiper Pos : "
locate 2,12
print Wiperposition
Wait 25 mS
goto Main
Sub getdata
Set CCWLED on
Wait 1 mS
instring=HSerReceive
locate 3,0
print instring
Wait 250 mS
Set CCWLED off
End Sub
Try this. Do not print within the ISR, raise a flag and handle within main body.