Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC12F1822 +GSMmodem+ HTTPREAD HELP REQUIRED

mastero

Member
Hello friends,

I am trying to use 12F1822 usart but all i am getting on PC terminal is gibbrish.
in simulation it works fine.

Can someone pls tell me whats wrong here.

Thanx in advance.
cheers
mastero

AllDigital
TRISA = %00011000
PORTA = 0

Dim i As Byte
Symbol led = PORTA.5
UART1_Init 19200
WaitMs 100
led = 1

UART1_Write "START", CrLf
loop:
UART1_Get i
If UART1_Data_Ready > 0 Then
UART1_Write "Number: ", #i, CrLf
Toggle led
WaitMs 50
Endif
Goto loop
 
What's between the PIC UART and the PC? Do you have a MAX232 chip or a UART-USB converter chip?
 
Probably the most useful diagnostic for getting UART communications going is to send the character capital 'U' (0x55) in a repetitive loop. It is an alternating sequence of 1's and 0's so that you can reliably trigger a traditional oscilloscope to verify the bit timing and the inter character spacing.
 
Have you setup the CONFIG word/Oscillator Control Register for your oscillator settings?
Have you informed whatever compiler you're using of the frequency you're working at?
 
If you haven't specified anything, the default configuration will probably be the following:

Internal clock at 4Mhz and MCLR as digital input.

And then you have to control the overflow pin of the rs232 buffer or the data input will be blocked, but for the beginning if you do not supply a lot of data in a row it should work.

'12F1822
'Fuses
#define CONFIG1 = 0x0F84
#define CONFIG2 = 0x1CFF
'Clock Mhz
#define CLOCK_FREQUENCY = 4

AllDigital
TRISA = %00011000
PORTA = 0

Dim i As Byte
Symbol led = PORTA.5
UART1_Init 19200
WaitMs 100
led = 1

UART1_Write "START", CrLf

loop:
UART1_Get i
If UART1_Data_Ready > 0 Then
UART1_Write "Number: ", #i, CrLf
Toggle led
WaitMs 50
Endif
Goto loop
 
Internal clock at 4Mhz and MCLR as digital input.

'12F1822
'Fuses
#define CONFIG1 = 0x0F84
#define CONFIG2 = 0x1CFF
'Clock Mhz
#define CLOCK_FREQUENCY = 4

Not familiar with oshonsoft... will that #define set the OSCCON register?

That CONFIG1 word will set it to use the INTOSC, but the OSCCON register defaults to 500KHz MF
 
Try this other way:

The first thing is to remove the WaitMs 50.
Incorporate buffer error control.

'12F1822, v1.1
'Fuses
#define CONFIG1 = 0x0f84
#define CONFIG2 = 0x1cff
'Clock Mhz
#define CLOCK_FREQUENCY = 4

AllDigital
TRISA = %00011000
PORTA = 0

Dim i As Byte
Symbol led = PORTA.5
UART1_Init 19200
WaitMs 100
led = 1

UART1_Write "START", CrLf

loop:
UART1_Get i
If UART1_Data_Ready > 0 Then
UART1_Write "Number: ", #i, CrLf
Toggle led
'WaitMs 50
If RCSTA.OERR = True Then Call _error_usart()
Endif
Goto loop
End
'Manages the blocking of the USART in Rx mode
Proc _error_usart()
Dim _papelera As Byte
'More data entered than was extracted (blocked)
RCSTA.CREN = 0 'Disable, continua recepción
_papelera = RCREG 'Clear buffer usart
_papelera = RCREG
RCSTA.CREN = 1 'Enable, Continuous Receive Enable bit*/
End Proc
 
Last edited:
Hey Guys need help again with PIC12F1822

All is working fine with communication between GSM modem and 12F1822
Now i want to get data from the server using the same setup using AT+HTTPPARA

I can see the data on the terminal but can not store the value in variable aaray

This is what i see in the terminal
*************************************************************************************************************
AT+NETOPEN
OK
+NETOPEN: 0
AT+HTTPINIT
OK
AT+HTTPPARA="URL","http://xxx.xxx.xxx.xxx:xxxx/api?action=receivemessage&username=12345&password=12345"
OK
AT+HTTPACTION=0
OK
+HTTPACTION: 0,200,511
AT+HTTPREAD=0,500
OK
+HTTPREAD: 500
<?xml version="1.0" encoding="utf-8"?>
<response>
<action>receivemessage</action>
<data>
<message>
<messageid>d8da07d7-912e-455a-a6c9-b7061b6a9572</messageid>
<originator>+00000000000</originator>
<recipient>+000000000000</recipient>
<messagetype>SMS:TEXT</messagetype>
<messagedata>@12345#0000:CP+12345*</messagedata>
<senttime>2024-07-09 13:19:15</senttime>
<receivedtime>2024-07-09 13:23:54</receivedtime>
</message>
</data>
+HTTPREAD: 0
AT+HTTPTERM
OK
*************************************************************************************************************

I just want to catch this data @12345#0000:CP+12345*

My code is below
*************************************************************************************************************
check_for_message:

j = 0
i = 0
startmark = False
msgreceived = False
If RCSTA.OERR = True Then
Gosub reset_usart
Endif

Gosub open_net
Gosub receive_command

loop:
Hserget serdata
If serdata > 0 Then
led=1
If serdata = 0x40 Then
msgreceived = True
Endif
If serdata = 0x23 And msgreceived = True Then
startmark = True
Endif
If serdata = 0x2a Then
startmark = False
led=0
Endif
If startmark = True Then
data(j) = serdata
If j = 31 Then
j = 0
Else
j = j + 1
Endif
Endif
Endif
i = i + 1
If i = 10000 Then
Gosub close_net
Exit Sub
Endif
Goto loop
Return
*************************************************************************************************************

Any help or direction shall be great thanks guys

Cheers
Mastero
 
Update:
Tried to break the input data into parts

AT+HTTPREAD=0,80

REPLY from NET

+HTTPREAD: 80
messagedata>@12345#0000:CP+12345*</messagedata>
<senttime>202
+HTTPREAD: 0

Still the 12F1822 did not pick it up.

any ideas ?
 
Last edited:

Latest threads

Back
Top