Close

Pull ups, DTMF, ISR and user interaction

A project log for DIAVOX Cellphone

Turning an old diavox phone into a cellphone. No smart stuff, just a telephone. Pick up the handset and dial just like the old days.

anders-helgessonAnders Helgesson 11/30/2024 at 21:480 Comments

When running through some tests in my code the SDA and SCL were low, it seems like stupid me forgot to include the pull up resistors for the MCP2221A, so I added them to the breadboard.

Stupid me had also made the assumption that I2C worked kinda like CAN between chips but that is not the case so I have to poll the SLG46826V from the MCU to get which key is pressed.

The now smarter me have decided to use one of the free GPIO's on the pico-lipo to tell if a key is held down by setting the pin from the SLG46826V. Thus when the handset is picked up and instead of constantly polling the SLG46826V on the I2C bus the MCU will check the GPIO pin instead and as soon as it goes high it will communciate with the SLG46826V to get which key is pressed.

But constantly polling the GPIO pin isn't very efficient either so using an ISR(Interrupt Service Routine) for the pin is better. Then when the device is idling with the handset off it will play the dial tone. The pin goes high and now it get into the ISR and it will poll which key is being held down, plays the DTMF key tone until the pin goes low. When the pin goes low the ISR will send which key was pressed somewhere for processing by the MCU and reset the ISR.

That left me with some questions.

How long is the timer before a call is initiated in a DTMF system?

Apparently it's between 4-6 seconds, emergency numbers are acted upon directly when received.

How do I manage the countdown timer?

Probably best to have a state for when dialing have been started and it handles the timer and emergency number dailing. So the ISR checks if it's the first digit entered and switches to this dialing state. The ISR then resets the timer each time a button is pressed or constantly with a key held down.

What happens in a DTMF system if too many digits entered? Is there a limit to how many digits can be received?

There is no real limit in the system but the International Telecommuncations Union standard E.164 have specified that 15 digits are allowed which also includes the country code. So I will go with a 15 digit limit in my virtual DTMF system. In a PSTN(Public Switched Telephone Network) numbers beyond the 15th will just be ignored so I'll go for the same. The user can bash the keypad all day but only the first 15 digit are used.

What happens if a user holds down two keys in a DTMF system?

It seems to be up to the implementation of the DTMF phone in question. So I guess I will see what I can do in the SLG46826V to prevent it and only register the first key and any other keys pressed keys are ignored.

Where do I store the digits pressed?

I can have 2 vectors for these, one local inside the state which keeps track of the digits that have been entered and a global that is set once the timer expires, that can also be used for a recall functionality.

I've added a dialing state to my code which it will switch to when the first digit is received. Now I have to use the greenpak designer software to make the keymatrix scanning work and ofcourse connect all the hardware together.

Yesterday one of the feature creeps show up again and he whispered that instead of using a FXMA2012 levelshifter for the framework expansion card you should you use an I2C isolator instead like the ADM3260. Suddenly one of the other feature creeps yelled out "Then you wouldn't be able to interface with a 1.8 volt I2C bus! Get away from him!". They started arguing about it, how QWIIC is 3.3V and the ADM3260 would also be able to interface with 5V so it would be STEMMA compatible. They came to the conclusion that interfacing with a bus that already have a master is the job of another tool like the bus pirate. This tool would be used to test QWIIC and STEMMA stuff. What do you think they asked and looked at me. It's difficult to ignore them but I have to until this project is finished.

Discussions