11-14598

Embed Size (px)

Citation preview

  • 8/6/2019 11-14598

    1/8

    Consumer/Industrial - Telephone Call Logger

    August 29, 2003 Document No. 001-35960 Rev. ** 1

    AN2118

    Author: MehmetZeki SONMEZAssociated Project: Yes

    Associated Part Family: CY8C25xxx, CY8C26xxxGET FREE SAMPLES HERE

    Software Version: Not AvailableAssociated Application Notes: None

    Application Note AbstractThis Application Note introduces a complete and detailed PSoC project. Telephone Call Logger keeps the detailed record ofapproximately 945 phone calls (7-digit number is assumed to be one phone call) including date, start time and the duration ofthe phone call in the PSoC device. Users can get this detailed report into the PC environment by using free software, which isincluded in the project file. When records reach near full capacity of the Flash memory, an LED will turn on to show that it isnecessary to backup the data. Software gets the data from PSoC, organizes it and prepares a printable version. Additionally, itsends the date and time information to the PSoC. The external parts in this project can be obtained easily in the market.

    IntroductionTo get the DTMF code, a DTMF receiver IC and audiointerface for telephone line is used. A phone-in-use circuitis used for measuring the duration of call, and finallyMax232 is used for the serial communication.

    The PSoC device performs the real-time clock, serialcommunication operations. It stores data to the Flashmemory and controls overall operation.

    The Real-Time ClockReal-time clock is necessary for the project in order tokeep the record of when the phone call is made (date andstart time). Time changes every minute not in everysecond in this project. Real-time clock is not used formeasuring the duration of the phone call.

    Two 16-bit PWMs and one 8-bit PWM are used for thereal-time clock operations.

    PWM16_1 generates a 600 Hz clock at its output.

    PWM16_2 generates a 1 Hz clock from its 600 Hz inputclock. (PWM16_1 is necessary for PWM16_2.)

    Because the output of PWM16_2 is 1 Hz, or say itproduces a 1-second delay, it is used for determining theduration of call.

    8-bit PWM8_1 produces a clock signal of period 1 minute.(1/60) Hz clock (PWM16_2 is necessary for PWM8_1.)

    The assembler code for the date and time is placed insidethe PWM8_1 interrupt .asm file. Each minute, PWM8_1produces an interrupt and the current time is updated.PWM8_1int.asm:

    inc [minute]

    cmp [minute],60

    jnz end

    mov [minute],00

    inc [hour]

    cmp [hour],24

    jnz end

    mov [hour],00

    inc [day]

    mov A,[month]

    index month_table

    cmp A,[day]

    jnz end

    mov [day],01

    inc [month]

    cmp [month],12

    jnz end

    mov [month],1

    end:

    reti

    month_table:

    db 00,32,29,32,31,32,31,32,32,31,32,31,32

    [+] [+]

    http://www.cypress.com/samplerequesthttp://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_1http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_1http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_1http://ccc01.opinionlab.com/o.asp?id=Text1&prev=docurate_001-35960_pdf_p_1http://www.cypress.com/samplerequest
  • 8/6/2019 11-14598

    2/8

    AN2118

    As seen in the code, every minute the time is changed.The 24 MHz system clock may not be very accurate.However, date and time information will be transferred toPSoC when users use the telephone call logger software.

    Note that February is assumed to be 28 days. (Do notconfuse; 1 day is written to each month in the month tablein the assembly code.)

    The variables of minute, hour, day and month are stored inthe RAM area. They are defined in main.asm file.

    Getting DTMF CodeBy using an audio interface for telephone line and a DTMFreceiver circuit, the DTMF code of dialed numbers can beeasily stored in the memory of PSoC.

    Figure 1. Audio Interface, DTMF Rx IC, and PSoC Flow

    When a button is pressed on the phone, then the Std pinof the DTMF receiver IC will be logic 1 and there will be a4-bit code at the pin 4 of the receiver according to thetable shown below:

    Table 1. Corresponding DTMF Code

    DialedNumber Q4 Q3 Q2 Q1

    1 0 0 0 1

    2 0 0 1 0

    3 0 0 1 1

    4 0 1 0 0

    5 0 1 0 1

    6 0 1 1 0

    7 0 1 1 1

    8 1 0 0 0

    9 1 0 0 1

    0 1 0 1 0

    * 1 0 1 1

    # 1 1 0 0

    When the Std pin is logic high then the code in thegeneral-purpose interrupt assembler file is executed. (Stdis connected to pin 15 of the PSoC and rising edgeinterrupt is selected in the Pin-out view.)

    When the Std pin of the DTMF receiver or pin 15 of thePSoC is logic 1 then PSoC will read the DTMF code fromthe DTMF receiver IC output (4 pin) and store it into the

    memory.

    For example, if button 5 is pressed on the phone thenStd will be logic 1 and the other four pins of the DTMFreceiver IC will be 0101. PSoC will read the 0101 andstore it as 05h in the memory. If button 6 is pressed,some bitwise operations will be performed and to usememory more efficient the 06h will be transferred to 05hmemory location and it will be 56h. 56h means button 5and 6 have been pressed, respectively.

    The date and time will be stored to memory just after thefirst button is pressed. When the phone is unavailable,PSoC will understand this by using a phone in-use circuit.Then the duration of the call will be stored into the

    memory. Finally, FFh will be placed, which means the callis finished.

    Table 2. Memory AllocationMinute

    DialedNumber

    Duration

    (Minute)

    Duration

    (Second)

    FFh

    For example, if the number 055 5980 is called on March25 at 15:33 and lasts 5 minutes 6 seconds, the memorymap will be like this:

    03

    19 0F 21 A5 55

    98 A0

    05 06 FF

    Numbers are in hexadecimal format. Note that becauseDTMF code says 0 is 0Ah (1010), 0 is stored as A in thememory location. The 0 in the dialed-number columns ofthe memory are meaningless.

    Column 1 (Month) March 03 = 03h

    Column 2 (Day) 25 19h

    Column 3 (Hour) 15 0Fh

    Column 4 (Minute) 33 21h

    Column 5..8 (D.Number) 0555 980

    A55598A0Column 9 (Duration Min.) 05 05h

    Column 10 (Duration Sec.) 06 06h

    Column 11 (Final) FFh End of detailsof call

    AudioInterface

    DTMFReceiver

    IC

    PSoC

    Std

    August 29, 2003 Document No. 001-35960 Rev. ** 2

    [+] [+]

    http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_2http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_2http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_2http://ccc01.opinionlab.com/o.asp?id=Text1&prev=docurate_001-35960_pdf_p_2
  • 8/6/2019 11-14598

    3/8

    AN2118

    August 29, 2003 Document No. 001-35960 Rev. ** 3

    FFh is placed once the phone call is finished. When a newcall is made, the details will be placed just after the lastFFh. When the 64-byte block in the RAM area is filled thenthese 64 bytes of data will be transferred to the Flashmemory.

    Writing to the FLASH MemoryThe data will be transferred to the Flash memory when the64 bytes of RAM is filled with phone-call details.

    1000h is the beginning address for storage of data in theFlash memory. This means 12 kilobytes of data can bebacked up in the Flash memory. If 7-digit phone numbersare dialed then PSoC can store up to 945 phone-call

    details in its memory. An LED will turn ON when Flashmemory is almost to capacity. Then the user can backupthe numbers in the PC by using the software that isincluded in the project.

    Writing to Flash memory is done with the E2PROM UserModule. Full details can be observed in the project file.

    Serial Communication with PCWhen the Receive Data button is clicked in the software,the PC will send the time and date information to thePSoC for better accuracy of real-time clock. PSoC willthen send the data beginning at address 1000h of Flashmemory and finally the data in the RAM area (maximum64 bytes).

    Serial communication is performed at 18750 bps. The RX8and TX8 User Modules are used for serial communication.Full details can be observed in the project file.

    The dialed numbers are converted to ASCII character byusing a table in Flash. Then they are sent to the PC.

    Using PC Software (CallLogger)First, select which comport you use then click on Button 1(Open Port).

    Click on the Button 2 (Receive Data) to get data fromPSoC Flash memory and RAM. Wait until the box just

    below the button 3, 4, 5 to be filled.Now, the data has been received. The form of data is thesame as with Table 2. It is recommended that you savethe received data by clicking on Button 4 (Save) so youcan use it whenever you want by loading it back byclicking Button 3 (Load).

    When you click on Button 5 (Convert), the data will beconverted into readable form in the box just above button6, 7, 8. Users can save this data for use in otherapplications or software such as Microsoft Excel byclicking Button 7.

    When you click on Button 8 (Convert), the semi-converteddata will be transferred to the grid. A much more readable

    form is then obtained and users can print this data byclicking Button 9 (Print).

    It is recommended that you always save the backup datayou get data from the PSoC.

    [+] [+]

    http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_3http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_3http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_3http://ccc01.opinionlab.com/o.asp?id=Text1&prev=docurate_001-35960_pdf_p_3
  • 8/6/2019 11-14598

    4/8

    AN2118

    Figure 2. Screenshot of CallLogger Software

    August 29, 2003 Document No. 001-35960 Rev. ** 4

    [+] [+]

    http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_4http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_4http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_4http://ccc01.opinionlab.com/o.asp?id=Text1&prev=docurate_001-35960_pdf_p_4
  • 8/6/2019 11-14598

    5/8

    AN2118

    Figure 3. Flow Diagrams

    The following is the flow diagram of main.asm; the most important events occur duringinterrupts.

    Wait until PC wants to communicatewith PSoC

    Get date and time information from PC andstore it in the RAM area

    If any data exists, send it from Flash to PCIf any data exists, send it from RAM to PC

    PC Software wants to communicate

    Initialize:Telephone is OFFInitialize Flash memory addressTurn LED (prt2_4) off; there is enough memory locationReset Date and TimeStart User Modules (PWMs, TX8, RX8)Clear RAM (fill it with EEh)

    The following is the flow diagram of psocgpioint.asm. When a button is pressed on thephone or when the call is finished, the following code will be executed.

    Check if DTMF code is generatedor phone has been hung up

    If it is the first dialed button thenstore the date and timeinformation into the RAM blocks

    Store the code for the pressedbutton into RAM

    Enable Interrupt for PWM16_2.Now the duration is started.Duration will change every second

    If this is not the first button thencontinue to store two pairs of codein one memory location withoutstoring date and time each time.

    DTMFenerated

    Phone not in useDisable PWM16_2 interruptStore the duration in the relatedRAM block

    If 64-byte block of RAM is filled,then transfer it to Flash memory

    Telephone call has finished.Phone not in use

    There is some simple stopwatch code in the PWM16_2 interrupt file. Duration willalways increment one second when the code is enabled in this interrupt file. Whenphone has been hung up the counting will be finished.

    August 29, 2003 Document No. 001-35960 Rev. ** 5

    [+] [+]

    http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_5http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_5http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_5http://ccc01.opinionlab.com/o.asp?id=Text1&prev=docurate_001-35960_pdf_p_5
  • 8/6/2019 11-14598

    6/8

    AN2118

    Figure 4. Block Diagram of Telephone Call Logger

    Audio Interfacefor telephone line

    DTMF Receiver

    Phone in-use indicator

    PSoC 26443

    4-bit digital codeWhen DTMF code isgenerated, this linewill be logic 1.

    There is a GPIOinterrupt for this pin.

    When telephone is inuse this line is 5V,otherwise it is 0V.

    There is a GPIOinterrupt for this pinto detect if phone hasbeen hung up.

    An LED willilluminate if Flash isalmost to capacity.Place here an LEDthrough 470 ohm. Max232

    August 29, 2003 Document No. 001-35960 Rev. ** 6

    [+] [+]

    http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_6http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_6http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_6http://ccc01.opinionlab.com/o.asp?id=Text1&prev=docurate_001-35960_pdf_p_6
  • 8/6/2019 11-14598

    7/8

    AN2118

    August 29, 2003 Document No. 001-35960 Rev. ** 7

    [+] [+]

    http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_7http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_7http://ccc01.opinionlab.com/o.asp?id=wRiLHxlo&prev=docurate_consumer_industrial___telephone_call_logger___an2118_12_pdf_p_7http://ccc01.opinionlab.com/o.asp?id=Text1&prev=docurate_001-35960_pdf_p_7
  • 8/6/2019 11-14598

    8/8

    AN2118

    About the AuthorName: Mehmet Zeki SONMEZ

    Title: Yeditepe University: Electrical &Electronics Engineering Student &Student Assistant (last year).

    Background: M.Zeki Sonmez is interested indesign of both analog and digital(including microcontrollers) circuits.In the near future his area of interestwill be RF Identification.

    Contact: [email protected] [email protected] Bloklari.Kanarya Apt.7.Blok D: 8Kayisdagi/ISTANBULTURKEY 34755+90 532 413 70 50

    Web Site: http://electronicsclub.cjb.net

    In March of 2007, Cypress recataloged all of its Application Notes using a new documentation number and revision code. This new documentationnumber and revision code (001-xxxxx, beginning with rev. **), located in the footer of the document, will be used in all subsequent revisions.

    PSoC is a registered trademark of Cypress Semiconductor Corp. "Programmable System-on-Chip," PSoC Designer, and PSoC Express are trademarksof Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners.

    Cypress Semiconductor198 Champion Court

    San Jose, CA 95134-1709Phone: 408-943-2600

    Fax: 408-943-4730http://www.cypress.com/

    Cypress Semiconductor Corporation, 2003-2007. The information contained herein is subject to change without notice. Cypress SemiconductorCorporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply anylicense under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control orsafety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use ascritical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. Theinclusion of Cypress products in l ife-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifiesCypress against all charges.

    This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwidepatent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee apersonal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivativeworks for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypressintegrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this SourceCode except as specified above is prohibited without the express written permission of Cypress.

    Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUTNOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves theright to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application oruse of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where amalfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress product in a life-support systemsapplication implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.

    Use may be limited by and subject to the applicable Cypress software license agreement.

    August 29, 2003 Document No. 001-35960 Rev. ** 8

    mailto:[email protected]:[email protected]://electronicsclub.cjb.net/http://electronicsclub.cjb.net/http://www.cypress.com/http://www.cypress.com/http://electronicsclub.cjb.net/mailto:[email protected]:[email protected]