SIM card access based on sim900

Source: Internet
Author: User

1. hardware environment

CPU: s3c2443x

GPRS module: sim900

 

The physical port connection between the CPU and sim900 is as follows:

 

Gph0 ------------- TX

Gph1 ------------- RX

Gph8 ------------- cts

Gph9 ------------- RTS

Gpf6 ------------- DCD

Gpe13 ------------- DSR

Gpf4 ------------- connect to the power supply pin of sim900 through the intermediate Analog Circuit

Gpg13 ------------- powerkey

Gpl9 ------------- Reset

The circuit diagram is as follows:

2. Software Environment

Wince6.0

 

3. Implementation

3.1 Implementation of serial port driver

(1) Add the following content about gprs to the createserialobject function of the ser_smdk2443.cpp file.

Cserialpdd * createserialobject (lptstr lpactivepath, pvoid pmdd, phwobj, DWORD devicearrayindex)

{

Cserialpdd * pserialpdd = NULL;

Retailmsg (true, (text ("Debug: createserialobject % d/R/N"), devicearrayindex ));

Switch (devicearrayindex ){

Case 0: // <uart0: GPRS

Pserialpdd = new cpdd2443serial0 (lpactivepath, pmdd, phwobj );

Break;

Case 1: // <uart1: Debug, glasdebg

Pserialpdd = new cpdd2443serial1 (lpactivepath, pmdd, phwobj );

Break;

Case 2: // <uart2: GPS

Pserialpdd = new cpdd2443serial (lpactivepath, pmdd, phwobj );

Break;

Case 3: // <uart3: Bluetooth

Pserialpdd = new cpdd2443seri_3 (lpactivepath, pmdd, phwobj );

Break;

}

If (pserialpdd &&! Pserialpdd-> Init ()){

Delete pserialpdd;

Pserialpdd = NULL;

}

Return pserialpdd;

}

 

(2) In the definition of cpdd2443serial0, if the following content is used to establish a physical connection between uart0 and TX/RX of sim900, hardware traffic control is not used in this design, therefore, the corresponding functional ports are not configured on the RTS and CTS terminals.

Class cpdd2443serial0: Public cpdd2443uart {

.....................

Virtual bool Init ()

{

..........................................

M_piopregs-> gphcon & = ~ (0x3 <0 | 0x3 <2 );

M_piopregs-> gphcon | = (0x2 <0 | 0x2 <2 );

M_piopregs-> gphudp | = (0x2 <(0) | 0x2 <(2 ));

M_piopregs-> gphudp & = ~ (0x2 <(16) | 0x2 <(18 ));

 

M_pdtrport = (volatile ulong *) & (m_piopregs-> gpfdat );

M_pdsrport = (volatile ulong *) & (m_piopregs-> gpgdat );

M_dwdtrportnum = 0;

M_dwdsrportnum = 3;

........................................................

Return cpdd2443uart: Init ();

}

Return false;

};

.......................................................

};

 

(3) serial port driver related registry, using com3

=================== GPRS: uart0 (physical com3 connector P1) (Serial) com3 =

[HKEY_LOCAL_MACHINE/Drivers/builtin/serial1]

"Devicearrayindex" = DWORD: 0

"IRQ" = DWORD: 1c

"Membase" = DWORD: 50000000

"Memlen" = DWORD: 30; 2C

"Interruptbitsshift" = DWORD: 0; UART 0 interrupt sub register shift bit.

"Isttimeouts" = DWORD: 200; every 512 ticks checking modem status.

"Prefix" = "com"

"Index" = DWORD: 3

"DLL" = "serial_smdk2443.dll"

"Order" = DWORD: 0

"Priority" = DWORD: 0

"Port" = "com3 :"

"Devicetype" = DWORD: 0

"Friendlyname" = "GPRS com3"

"TSP" = "unimodem. dll"

"Iclass" = "{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD }"

"Devconfig" = HEX: 10, 00, 00, 00, 00, 01, 00, 00, 4B, 08, 00, 00, 00

 

 

3.2 clock and I/O port control for the sim900 Module

This part of the control needs to be controlled according to the specific description of the datasheet of sim900.

 

(1) I added the following control code to oeminit () à configuregpio ():

/*************************************** * Kandi add start ************************************ ***/

//// // 3G //////////////////// ///////

# Ifdef mx500b

// Threeg_gpio4 = 1, normal mode: RF is working

S2443iop-> gplcon & = ~ (0x3 <12 );

S2443iop-> gplcon | = (0x1 <12 );

S2443iop-> gpludp & = ~ (0x3 <12 );

S2443iop-> gpldat | = (0x1 <6 );

# Endif

 

///////////// //////////////

// Maid

S2443iop-> gpfcon & = ~ (0x3 <12 );

S2443iop-> gpfcon | = (0x1 <12 );

S2443iop-> gpfdat & = ~ (0x1 <6 );

 

// Maid

S2443iop-> gpecon & = ~ (0x3 <26 );

S2443iop-> gpecon | = (0x1 <26 );

S2443iop-> gpedat & = ~ (0x1 <13 );

 

// Upls_cts

S2443iop-> gphcon & = ~ (0x3 <16 );

S2443iop-> gphcon | = (0x1 <16 );

S2443iop-> gphdat & = ~ (0x1 <8 );

 

// Maid

S2443iop-> gphcon & = ~ (0x3 <18 );

S2443iop-> gphcon | = (0x1 <18 );

S2443iop-> gphdat & = ~ (0x1 <9 );

 

// En_gprs

S2443iop-> gpfcon & = ~ (0x3 <8 );

S2443iop-> gpfcon | = (0x1 <8 );

S2443iop-> gpfdat | = (0x1 <4 );

 

// Maid

S2443iop-> gpgcon & = ~ (0x3 <26 );

S2443iop-> gpgcon | = (0x1 <26 );

S2443iop-> gpgudp & = ~ (0x3 <26 );

S2443iop-> gpgdat & = ~ (0x1 <13 );

 

# Ifdef mx500b

// Threeg_reset

S2443iop-> gplcon & = ~ (0x3 <10 );

S2443iop-> gplcon | = (0x1 <10 );

S2443iop-> gpludp & = ~ (0x3 <10 );

S2443iop-> gpldat | = (0x1 <5 );

 

For (I = 0; I <20; I ++)

{

I = I;

}

S2443iop-> gpldat & = ~ (0x1 <5 );

Oalmsg (1, (L "oeminit kandroid test 1111/R/N "));

# Else

// Upls_reset

S2443iop-> gplcon & = ~ (0x3 <18 );

S2443iop-> gplcon | = (0x1 <18 );

S2443iop-> gpludp & = ~ (0x3 <18 );

S2443iop-> gpldat | = (0x1 <9 );

 

For (I = 0; I <20; I ++)

{

I = I;

}

S2443iop-> gpldat & = ~ (0x1 <9 );

Oalmsg (1, (L "oeminit kandroid test 22222/R/N "));

# Endif

 

(2) Add the following content to the CMC. DLL driver.

Many of our products are communication modules, so CMC is created. DLL to control GPS, GPRS, 3G, RFID, BT and other modules. Add the following content in cmc_init () à cmcgpioinit () to meet the timing requirements of 3G and sim900 modules.

# Ifdef mx500b

// Threeg_reset

V_piop_cmc_regs-> gpldat | = (0x1 <5 );

Retailmsg (cmc_debug_message, (L "cmcgpioinit Kandi test 1111/R/N "));

# Else

// Upls_reset

V_piop_cmc_regs-> gpldat | = (0x1 <9 );

 

Sleep (1000 );

V_piop_cmc_regs-> gpgdat | = (0x1 <13 );

Retailmsg (cmc_debug_message, (L "cmcgpioinit Kandi test 222222/R/N "));

# Endif

 

4. Notes

 

(1) because our system does not use the hardware traffic control method, when creating a connection under the control panel of wince, the traffic control method must also be set to "NONE"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.