PDA

View Full Version : help me please



MICOCALI
- 23rd May 2005, 11:14
i write this code
but the program run in loop why


'************************************************* ******************************
@ device WDT_OFF, MCLR_OFF, HS_OSC, BOD_OFF, PWRT_ON, CPD_OFF, LVP_OFF
'************************************************* ******************************
INCLUDE "modedefs.bas"
DEFINE OSC 20
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1

CMCON = 7
VRCON = 0



' ************************************************** ****************************
INIT:
Pause 2000

LOOP:
Pause 500
HSerout ["AT*EIPS=1,1",13]
Pause 500

HSerin 2000,APRI,[WAIT ("*ELIP:")]

APRI:
High PORTB.4
Pause 1000
Low PORTB.4
Pause 15000
GoTo LOOP


End

Bruce
- 24th May 2005, 15:53
Goto Loop causes your program to run in a continuous loop.

This line; HSerin 2000,APRI,[WAIT ("*ELIP:")] will WAIT for 2 seconds,
then jump to the APRI sub-routine if ASCII chars *ELIP: are not received
within the timeout period.

Execution will also "fall-through" to APRI even if these characters "are"
received - so you have a continuous loop no matter what happens.

If you prefer to only enter the APRI sub-routine once these characters
are received, then change the timeout "label" from APRI to Loop.


INIT:
Pause 2000

LOOP:
Pause 500
HSerout ["AT*EIPS=1,1",13]
Pause 500

HSerin 2000,LOOP,[WAIT ("*ELIP:")]

APRI: ' Land here only when characters are received.
High PORTB.4
Pause 1000
Low PORTB.4
Pause 15000
Goto LOOP


Or or use a local label something like this;


INIT:
Pause 2000

LOOP:
Pause 500
HSerout ["AT*EIPS=1,1",13]
Pause 500

Loop2: ' Loop to here until characters are received
HSerin 2000,Loop2,[WAIT ("*ELIP:")]

APRI:
High PORTB.4
Pause 1000
Low PORTB.4
Pause 15000
Goto LOOP

MICOCALI
- 25th May 2005, 17:55
thank you for reply but i have one problem:

HSerin 2000,LOOP,[WAIT ("*ELIP:")] is true when i receve all caracter?(*elip:)

if yes what is the command for receve only two caracter for example *e
thank you carlo

Bruce
- 25th May 2005, 18:20
HSerin 2000,LOOP,[WAIT ("*ELIP:")] is going to wait until *ELIP: is received.
If *elip: (note it's in lower case) is received, it will not match.

If you need to wait for 2 characters, then only use 2 characters.

HSerin 2000,LOOP,[WAIT ("*E")]

MICOCALI
- 26th May 2005, 08:35
the telefone send *elip i confirm with hyper terminal ,i write
HSerin 2000,LOOP,[WAIT ("*E")] in the pic 16f628 but the pin portb4 not
on.
wy for you?

Bruce
- 26th May 2005, 15:02
the telefone send *elip i confirm with hyper terminal
If you are seeing *elip in hyperterminal, then wait for *e. Not *E.


i write HSerin 2000,LOOP,[WAIT ("*E")]

Have you tried this?

HSERIN 2000,LOOP,[WAIT("*e")]

MICOCALI
- 26th May 2005, 16:25
I write:
HSERIN 2000,LOOP,[WAIT("*e")]
but not run
I connect the pic with two resistore of 4,7 kohm direct at the phone if possible is this? not max 232

Bruce
- 26th May 2005, 16:40
Does your phone output RS232 or TTL level voltage?

Does your phone send serial data inverted or true?

MICOCALI
- 26th May 2005, 16:42
but is not important because the command Hserout is run very well i think

Bruce
- 26th May 2005, 16:47
It definitely "is" important if you want your PIC to communicate
with or receive serial data from your phone.

MICOCALI
- 26th May 2005, 16:53
I have ericsson 9600/8/n/1

MICOCALI
- 26th May 2005, 16:55
I supposed TTL level voltage can you teach me what is the method

Bruce
- 26th May 2005, 17:09
Sorry I don't know anything about this phone.

When you connect the phone to your PC to verify it's sending
data to hyperterminal, how are you connecting the phone to
your PC serial port?

When you connect your phone to the PIC, how are you making
this connection?

MICOCALI
- 26th May 2005, 17:21
I connect phone with hyper... with convertitor rs 232 ttl (max 232 ) and
i set Hyper.. with 9600 8 N 1
but when i send command at+cmss=1 the phone send message very well
WY for you

Bruce
- 26th May 2005, 17:40
OK, but how are you connecting the phone to your PIC?

MICOCALI
- 26th May 2005, 17:53
direct with two resistor

mister_e
- 26th May 2005, 19:22
Miiiiiiiiiip this is why. you must still use the Max232 ic to invert the serial data. OR, but it bet that will not work 100%, use serin/serout in inverted mode.

MICOCALI
- 12th June 2005, 16:13
the bit 14 is the register for setting the serial comunication at inverted mode but wich is the parameter for setting 9600 baud,no parity ,inverted.
For example mode=84 is 9600,no parity,true
thank you.
where is if possible search this parameter ,because i search in the data sheet but i dont watch never

mister_e
- 12th June 2005, 17:19
so now it imply that you use SERIN2/SEROUT2 or else. chances are that you'll never find anything in the datasheet since it's a PBP statement. You'll find the result in the APPENDIX A at the end of your PBP manual... there you'll find the right setting for SERIN2/SEROUT2 wich is.....16468

For SERIN/SEROUT you'll use 6

You can't tell to HSERIN/HSEROUT to drive inverted since it use the internal PIC hardware.

MICOCALI
- 14th June 2005, 12:18
I write this code and now run but not very well . sometime run at first ring , sometime run at five ring , wy for you?
'************************************************* ******************************
@ device WDT_OFF, MCLR_OFF, HS_OSC, BOD_OFF, PWRT_ON, CPD_OFF, LVP_OFF
'************************************************* ******************************
INCLUDE "modedefs.bas"
DEFINE OSC 4
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1
DEFINE DEBUGIN_MODE 1
DEFINE DEBUG_MODE 1
DEFINE DEBUGIN_REG PORTB
DEFINE DEBUGIN_BIT 4

CMCON = 7
VRCON = 0

' ************************************************** ****************************
INIT:
Pause 2000

LOOP:
Pause 500
HSerout ["AT*EIPS=1,1",13,10]
Pause 3000

Loop2

DebugIn [wait("*")]

APRI:
High PORTA.1
Pause 1000
Low PORTA.1
Pause 10000
GoTo LOOP


End