Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ARM] For watchdog timer of lpc2148

Status
Not open for further replies.

jitendrabaraiya

Junior Member level 2
Joined
Sep 24, 2014
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
282
hello everyone......


Shall send me a sample code of watchdog timer for lpc2148 .
I ave little bit stuck for my sim900 receive sms for its sdelay problem so
plz send me a it...



thanks in advance...
 

hello everyone .............

I am working on sim900 module with lpc2148 and write down the code for sms send and receive .
i success for send sms but i have a stuch error when i received sms when i write AT+CMGR=1 but i didnt receive it . shall tell me whats wrong in my follwing code .........


/**************************************************************************************************
Platform: LPC2148 Development Board.

Written by: Rohit Chauhan, NEX Robotics Pvt. Ltd.
Edited By: Sachitanand Malewar, NEX Robotics Pvt. Ltd.
Last Modification: 2010-30-08

This application code demonstrates UART1 peripheral on LPC2148.
On reset it sends a string and waits for a character to be received.
Compiled with: RealView MDK-ARM Version:4.12

Hardware Setup:-
Connect a DB9 cable between PC and UART1.
Set UART1/Xbee jumpers for UART1-RS232 operation
COMPORT Settings
Baudrate:-9600
Databits:-8
Parity:-None
Stopbits:1
Setup terminal software to receive data in string format

Clock Settings:
FOSC >> 12MHz (onboard)
PLL >> M=5, P=2
CCLK >> 60MHz
PCLK >> 15MHz
**************************************************************************************************/

/********************************************************************************

Copyright (c) 2010, NEX Robotics Pvt. Ltd. -*- c -*-
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

* Neither the name of the copyright holders nor the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

* Source code can be used for academic purpose.
For commercial use permission form the author needs to be taken.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Software released under Creative Commence cc by-nc-sa licence.
For legal information refer to:
https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode

********************************************************************************/


#include <lpc214x.h> //Includes LPC2148 register definitions


#define Fosc 12000000
#define Fcclk (Fosc * 5)
#define Fcco (Fcclk * 4)
#define Fpclk (Fcclk / 4) * 1

#define UART_BPS 9600 //Set Baud Rate here
extern unsigned char cmgf[]="AT+CMGF=1"; //Text format in GSM modem
extern unsigned char cmgsh[]="AT+CMGS=\"+919924421913\""; //Mobile number to which the msg is sent
unsigned char cmgr[]="AT+CMGR=1";
unsigned char newmsg=0x00;
unsigned char msgid;



void delay() //delay function
{
int i,j;
for(i=0;i<60000;i++)
for(j=0;j<200;j++);
}

unsigned char UART_Receive()
{
while((U1LSR&0x01) == 0);
return U1RBR;
}


void UART1_SendByte(unsigned char data) //A function to send a byte on UART1
{
U1THR = data;
while( (U1LSR&0x40)==0 );
}


void UART1_SendStr(const unsigned char *str) //A function to send a string on UART1
{
while(1)
{
if( *str == '\0' ) break;
UART1_SendByte(*str++);
}
}

void readmsg()
{
int i,j;
unsigned char p[500];
unsigned char q[30];

VICIntEnClr=0x80;
UART1_SendStr(cmgf);
UART1_SendByte(0x0D); // equivalent of
UART1_SendByte(0x0A); // enter key
delay();
UART1_SendStr(cmgr);
UART1_SendByte(msgid);
UART1_SendByte(0x0D);
UART1_SendByte(0x0A);
for(i=0;i<130;i++)
{
p=UART_Receive();
if(p=='%')
{
for(j=0;j<10;j++)
q[j]=UART_Receive();
q[10]='\0';
IO1SET=0x00070000;
break;
}
}
UART1_SendStr(cmgf);
UART1_SendByte(0x0D); // equivalent of
UART1_SendByte(0x0A); // enter key
delay();
UART1_SendStr(cmgsh);
UART1_SendByte(0x0D);
UART1_SendByte(0x0A);
delay();
UART1_SendStr(q);
UART1_SendByte(0x1A);
delay();
UART1_SendByte(0x1A);
IO1SET=0x00080000;
}

void uart1_irq() __irq
{ //ISR if anything is recieved in UART1
unsigned char p[13];
unsigned char q;
int i;

q=U1RBR;
if(q=='+')
{
for(i=0;i<12;i++)
{
p=UART_Receive();
}
msgid=p[11];
p[12]='\0';
UART1_SendStr(p);
UART1_SendStr(cmgf);
UART1_SendByte(0x0D); // equivalent of
UART1_SendByte(0x0A); // enter key
delay();
UART1_SendStr(cmgsh);
UART1_SendByte(0x0D);
UART1_SendByte(0x0A);
delay();
UART1_SendStr(p);
UART1_SendByte(0x1A);
delay();
UART1_SendByte(0x1A);
IO1CLR=0x000F0000;
IO1SET=0x00020000;
newmsg=0x01;
}

VICVectAddr=0;
}

void Init_UART1(void) //This function setups UART1
{
unsigned int Baud16;
U1LCR = 0x83; // DLAB = 1
Baud16 = (Fpclk / 16) / UART_BPS;
U1DLM = Baud16 / 256;
U1DLL = Baud16 % 256;
U1LCR = 0x03;
U1IER=0x01;
U1FCR=0X07;
VICIntSelect&=0xffffff7f;
VICVectAddr2=(unsigned int)uart1_irq;
VICIntEnable|=0x00000080;
VICVectCntl2=0x20|7;
}

int main(void)
{
VICIntEnClr=0x00000080;

PINSEL0 = 0x00050000; // Enable UART1 Rx and Tx pins
PINSEL1 = 0x00000000;
PINSEL2 = 0x00000000;

Init_UART1();


IO1DIR=0xFFFF0000;

UART1_SendStr("ATe0\r\n");
delay();


UART1_SendStr("AT+CMGD=1,4\r\n");
delay();

UART1_SendStr("AT+CNMI=3,1,0,0,0\r\n");
delay();

IO1SET=0x00010000;
U1IER=0x01;
while(1)
{
IO1CLR=0x000F0000;
while(newmsg==0x00);
newmsg=0x00;
readmsg();
VICIntEnable=0x80; // here it branches to ISR
}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top