Sony Ericsson Automatic meter reading with M bus Application Note Download Page 10

  METERING AND M BUS 

 
 
 
 

main() 

 

int InCall = 0; 

 int 

NumBuf[13]; 

 int 

TmpBuf[255]; 

 

prs(0);   

 

chcrt(1); /*Create a channel for send/rcv data*/ 

 

prtf(“\n Script Created!”); 

 

 

/* Setup SPI bus and Max3100 interface */ 

 

if(mxc(MAXCFGWORD)) /* Enable,Sync High, every 2 bytes*/ 

 { 
  prtf(“\n 

Max3100 

Configured!”); 

 } 
 

 while 

(1) 

 { 
  int 

i; 

 

 

/*wait for incoming call*/ 

 

 

if(gtb(CALL_STATUS) == RINGING) 

  { 

 

 

 

mset(NumBuf,0,13); /*Clear number buffer*/ 

   clip(NumBuf,12); 

 

/* get incoming number*/ 

   prtf(“\n 

Number 

%s”,NumBuf); 

   if(scmp(NumBuf,DATA_NUMBER,12) == 0) /*if number 
matches*/ 
 

 

 

    /*answer 

call*/ 

    chw(1,"ata\n\r",5); 
 

 

 

 

/* wait for data mode */ 

    for(i=0; 

i< 

CALL_COUNT;i++) 

 

 

 

 

     st 

chsts(1); 

     prtf("\n 

chsts 

%d",st); 

 

 

 

 

 

if (st & 0x02) /* check second bit of status for 

DCD */ 
 

 

 

 

 

 

 

 

 

 

 

  break; /* data carrier detect */ 

 

 

 

 

 

 

 

 

 

 

dlyms(2); /* wait 100ms */ 

 

 

 

 

 

 

 

 

/* clear AT response from channel*/ 

    chr(1,TmpBuf,255); 
 

    if(i 

CALL_COUNT) 

 

 

 

 

     /*if 

count 

hasn't 

expired, set to in call*/ 

 

 

 

 

 

prtf(“\n In Call!”); 

 

 

 

 

 

InCall = 1; 

 

 

 

 

 

 

 

  } 
 
  if(InCall) 
  { 
   DoMBUS(); 

   st 

chsts(1); 

 

 

 

InCall = st & 0x02;  /*Make sure still in data call*/ 

  } 
  else 
  { 
 

 

 

prtf(“\n waiting for Call!”); 

 

 

 

dlys(1);  /* poll every 1 second when out of call */ 

  } 
 

} /*end while*/ 


 

 
 
 

LZT 123 8014 R1A

  

10 

Summary of Contents for Automatic meter reading with M bus

Page 1: ...Application Note Embedded Applications Automatic meter reading with M bus...

Page 2: ...Mobile Communications reserves the right to make modifications additions and deletions to this manual due to typographical errors inaccurate information or improvements to programs and or equipment a...

Page 3: ...ntroduction 4 2 MBUS support in Embedded Applications 5 2 1 Implementation 5 2 1 1 Hardware Setup 6 2 2 The Script 6 2 3 Testing the Application 7 2 4 Flexibility 7 2 5 Metering Application Script MBU...

Page 4: ...imply to the radio device s existing interfaces to provide an extra level of functionality This is done in the context of an application which uses MBUS as its communication mechanism the Metering Bus...

Page 5: ...bits This can then be communicated to a metering device The embedded application has driver function calls for the MAX3100 device that allow simple configuration of and communication through the devic...

Page 6: ...sits in a loop waiting for an incoming data call that requests an MBUS session be setup Once a call is received and checked to be from the correct number the module answers the call and calls the DoM...

Page 7: ...Tool from www viddata com The debug prints from the application can be monitored if the service pin is asserted on the radio device and UART2 is monitored at 115200 baud 8 data 1 start 1 stop bit The...

Page 8: ...NT 10 100ms receive wait char Recp 261 char iRec 261 int st operates on Recp and iRec GetMBUSData int RcNotRsp Get MBUS data from Channel or Device Contains MBUS packet validation algorithm int Size 0...

Page 9: ...en 0 return len DoMBUS int Sz int Cnt 0 start transmission get whole MBUS packet from Data Channel Sz GetMBUSData 1 send bytes over uart if mxs Recp Sz Sz prtf n Sent data to Max3100 Cnt 0 while gtf M...

Page 10: ...ng number prtf n Number s NumBuf if scmp NumBuf DATA_NUMBER 12 0 if number matches answer call chw 1 ata n r 5 wait for data mode for i 0 i CALL_COUNT i st chsts 1 prtf n chsts d st if st 0x02 check s...

Page 11: ...METERING AND M BUS LZT 123 8014 R1A 11 3 References 1 MBUS A Documentation www m bus com 2 MAX3100 Component data sheet www maxim ic com...

Reviews: