View previous topic :: View next topic |
Author |
Message |
Jim90
Joined: 27 Apr 2013 Posts: 55
|
interface dspic33 with sim900 |
Posted: Sun Jul 20, 2014 6:56 am |
|
|
I need to interface a dspic33 with sim900 module.
I use the code below without success, is anyone who know what is going wrong ?
Code: |
#include <string.h>
#define BUFFER_SIZE 32
BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
#int_rda
void serial_isr() {
int t;
buffer[next_in]=fgetc(GPRS);
t=next_in;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t; // Buffer full !!
}
#define bkbhit (next_in!=next_out)
BYTE bgetc() {
BYTE c;
while(!bkbhit) ;
c=buffer[next_out];
next_out=(next_out+1) % BUFFER_SIZE;
return(c);
}
void main()
{
enable_interrupts(int_rda);
int count;
char received_data[10];
fputs("\r\n\Running...\r\n",PC);
do {
delay_ms(10000);
fprintf(PC, "\r\nBuffered data => ");
while(bkbhit)
fputc( bgetc(),PC );
} while (TRUE);
}
|
|
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sun Jul 20, 2014 7:39 am |
|
|
Jim,
You dont say what is not working or show any of the setup for
the processor or serial you are trying to use. How are we
supposed to come to any helpful conclusions.
Items to consider:
How do you know the DsPIC is running?
How is the module connected to the DsPIC?
What serial speed are you using?
You enable RDA interrupts but not global...
Are you familiar with the Autobaud function and it's effects on the serial communications?
You dont appear to be doing any of the initialization required by the datasheet.
How are you powering on the module?
How are you monitoring the Status line to know the module is ready?
You are supposed to monitor Status then wait at least 2.2 seconds for it to go active after Reset.
You need to do some reading.........
ftp://imall.iteadstudio.com/IM120417009_IComSat/DOC_SIM900_Hardware%20Design_V2.00.pdf _________________ Google and Forum Search are some of your best tools!!!! |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Jul 21, 2014 6:42 am |
|
|
Hi,
Post a link to the 'SIM900' you are using. In most of the cases I've encountered, telling us you are using a 'SIM900' really means a SIM900 module mounted to some type of carrier board with on-board interface components such as a MAX232 (RS232) or FTDI232 (USB). In the case of a *true* SIM900, just the naked module, the communications interface is a logic level UART that can connect directly to the PIC. But, I doubt that is what you've got!
Also, the SIM900 will not be transmitting data continuously, you have to initiate the communication, such as by sending the 'AT' prompt.
John |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Jul 21, 2014 7:37 am |
|
|
1) no include of the processor type
2) no fuses
3) no clock selection
4) no use RS232(... options)
all mean no way anyone here can cut/patse/test your program....
hth
jay |
|
|
|