PDA

View Full Version : LOW PORTA cause serin2 not working.



mikewen
- 23rd August 2009, 20:58
Really need some help here.
I spent the whole weekends still not able to figure out the problem:
LOW PORTA.4
will cause serin2 stop working

If I comment out the ' LOW PORTA.4 ' in my code.
It works fine.

Can someone shed any light onto the problem ?
BTW, I use PBP250A. the chip is PIC12F635.



Include "modedefs.bas"

OSCCON = $60
TRISA = %11111110
PORTA = GPIO
BaudRate CON 188

STR1 VAR BYTE[12] 'Use as Lat and other
STR2 VAR BYTE[12] 'Use as Log
T Var BYTE

RS232_out var PORTA.1
GPS var PORTA.2
RS232_in var PORTA.5

GPIO.0 = 0
GPIO.1 = 0
GPIO.2 = 1
GPIO.3 = 1
GPIO.4 = 0
GPIO.5 = 1

Init:
SERout2 RS232_out,BaudRate,["at+clip=1",10,13]
SERIN2 RS232_in,BaudRate,2000,Init,[WAIT("OK"),T]


read 1,STR1[0]
if STR1[0] = "1" THEN
LOW PORTA.4 'Here is the problem
SERout2 RS232_out,BaudRate,["On",10,13]
else
HIGH GPIO.4
SERout2 RS232_out,BaudRate,["Off",10,13]
endif

PAUSE 1000

SERIN2 RS232_in,BaudRate,[WAIT("+CLIP: ",34,"+8600"), STR STR2\12]
'Not enough RAM, use Lat to get caller id

select case STR2[0]
Case "1"
write 1,STR2[0]
Case "2"
write 1,STR2[0]
case "3"
'Get Tracking
SERout2 RS232_out,BaudRate,["ATA",10,13]
PAUSE 1000
SERIN2 GPS,BaudRate,2000,Reboot,[WAIT("$GPGGA,"),Skip 11,STR STR1\12,STR STR2\12] ' Fill the arrays with received data.
SERout2 RS232_out,BaudRate,["AT+vts=*;+vts=",STR1[0],";+vts=",STR1[1],";+vts=",STR1[2],";+vts=",STR1[3],";+vts=",STR1[5],";+vts=",STR1[6],";+vts=",STR1[7],";+vts=",STR1[8],10,13]
PAUSE 5000
SERout2 RS232_out,BaudRate,["AT+vts=#;+vts=",STR2[0],";+vts=",STR2[1],";+vts=",STR2[2],";+vts=",STR2[3],";+vts=",STR2[4],";+vts=",STR2[6],";+vts=",STR2[7],";+vts=",STR2[8],10,13]
PAUSE 5000
end select
SERout2 RS232_out,BaudRate,["ATH",10,13]

Reboot:
@ goto $

mackrackit
- 23rd August 2009, 21:04
Try replacing PORTA with GPIO???
That chip does not have an A.

mikewen
- 23rd August 2009, 21:38
Try replacing PORTA with GPIO???
That chip does not have an A.

Tried that. Actually, I used GPIO.4 in the first place.

I tried GPIO.0 too, but for GPIO.0, always stay low,
not able to set high.

Darrel Taylor
- 23rd August 2009, 21:48
I think this might help ...

AllDigital.pbp
http://www.picbasic.co.uk/forum/showthread.php?t=11100

Or you could just ...
CMCON0 = 7

But AllDigital would have told you that too.

hth,

mikewen
- 23rd August 2009, 21:59
Tried CMCON0 = 7 , still the same.

Thank you for your help, it would useful if I decide to use other chips.


I think this might help ...

AllDigital.pbp
http://www.picbasic.co.uk/forum/showthread.php?t=11100

Or you could just ...
CMCON0 = 7

But AllDigital would have told you that too.

hth,

Darrel Taylor
- 23rd August 2009, 22:21
Woops,

Also change ...

TRISA = %11111110

to

TRISA = %11111100

RS232_out is on PORTA.1
<br>

No that won't matter, never mind. Duh!

mackrackit
- 23rd August 2009, 23:43
What is "PORTA.4" connected to?

Archangel
- 28th August 2009, 04:18
No I have not looked at the data sheet . . .


TRISA = %11111110
PORTA = GPIO

I see you aliased GPIO as portA, shouldn't you also alias the TRISIO as TRISA, for this to work ?


TRISIO = TRISA
GPIO = PortA
PortA = %00101100
TrisA = %11111100