ECE153B Project - Calculator

By Yuxiao Luo and Ming Wen

Week 1 (Before 3.1):

We used a fair amount of time to decide what parts we will use. For the LCD Display, we bought a 20x4 and a 16x2 as a back up type. For the keyboard, we planned to use digilent PmodKypd and we had a cheaper type -- a membrane switch keypad -- as a backup plan.

We were originally trying to implement sound effects when pressing button, by connecting though the audio jack with my portable stereo. But this "bonus" part is never tried as we ran out of time to even finished the first two steps.

​Feb 28 Update:

  • Our components had arrived.

  • We were also trying to figure out the datasheet and pin configuration of our 20x4 Sunfounder I2C 2004 LCD Display.


Week 2 (3.1-3.7):

Goal:

  1. Connect stm32l476 board to the PCF8574T expander on the back of the lcd. Try to send a message and display that message on the screen.

  2. We just finished Lab3 at this week. And we're really in a rush to start off our final project.

March 5th Update:

  1. Yuxiao tried to find the right library for the LCD display. However, yuxiao is not sure about which specific library to use for stm32Lxxx, the type of board that we use, and found three different libraries for different microcontrollers(Arduino, stm32Fxxx, stm32HAL). He narrowed down target to one specific library and decided to wrote code to check if the library is correct.

  2. Ming and Yuxiao set up the hardware and wiring part.

Week 3: (3.8-3.15)

A realy hard week

  • There's an adapter connected with the 20x4 LCD to help communicate between the external microcontroller with the pins in the board of the LCD screen. However, we couldn't display the message that we want to display. So Yuxiao debugged in two direction:

  • 1. Whether there is bug in the I2C process (from stm32 to the adapter PCF8574).

  • 2. Whether there is bug in the display process (from adapter PCF8574 to pins on board)

  • Eventually Yuxiao noticed that he actually forgot to wrote a Systick initialization function in the main.c and there's a mismatch of pin configuration in I2C function. So he fixed those two badass bugs and joyfully found that the message is now displayed on the screen.

Staring on the connecting Keypad:

  1. Yuxiao was having headache and not feeling well this week. So Ming had to stand afront, set up the hardware of keypad and wrote code of it. However, Ming was having a difficult time understanding how the internal circuit of the keypad works and struggled to wrote workable code.

  2. At first, we both thought that we should connect both Col1-4 and Row1-4 to the GPIO input in the stm32. However, after reading through the reference manual of PmodKypd, we found that the manual asks us to only connect the Row to GPIO input and COl to GPIO outputs. It reads that we need to first set all the COL as HIGH, and then consecutively set them to LOW, so that when one button is being pressed (switch closed), the ROW input GPIO will received a change of voltage from high to low.

  3. Ming managed to write some code with respect to the instruction in the manual as mentioned above.

Week 4 (3.16 - 3.22):

  1. Luckily, Yuxiao's immune system is strong enought to fight through that period of illness! He recovered! Yuxiao looked through the code Ming's has written and found several really severe bugs: a. Ming was trying to set PA0, 5, 1, 2 as output types and connect them to COL1-4, however, he wrote "10" into GPIO->MODER instead of "01", which is the actual right configuration values! This was honestly disappointing, as this type of intolerable and careless mistake took Yuxiao much time and energy to find and wasted alot of time.

  2. Yuxiao kept looking through the original version of code that Ming wrote and found more bugs:

a) As we're using PE10-13 for GPIO input, we should also write EXTI15_10_IRQHandler to handle the interrupts. However, MIng's code was initializing and implementing the line IRQHandler function respectively, like EXTI10_IRQHandler, EXTI11_IRQHandler... which is a wrong way to go. So Yuxiao fixed this error and reimplemented the EXTI15_10_IRQHandler.

b) Ming made the same mistake that Yuxiao made in the LCD part -- He forgot to initialize the EXTI_initialization funtion in the main function.

c) Other than that, Yuxiao changed the PUPDR to No push-up no pull-down and the output type to push-pull from open-drain.

  1. In order to check if the GPIOs is able to receive and detect the interrupts from the keypad, Yuxiao used UART and managed to print the value of row and col of the pressed button on Termite. After fixing the bugs, the keyboard finally starts to print something! However, our program constantly is printting "4", which indicating an interrupts constantly int the fourth row, even though no buttons is pressed in the 4th row. Yuxiao looked into the EXTI->PR to check the bit values for PE10-13, and saw that PR13 is always set high, whle PR10,11,12 are low.

  2. This bug is weird. And this is also where we got stuck at, even after a merciful postponed deadline. Yuxiao spent Friday and Sunday trying to figure out how to get rid of this, and still failed. We also tried to set the COL GPIO to input type, in hope that it might make some difference to behaviors, but still, nothing changed. Termite kept printing "4", and the deadline has come.

Final words:

It is actually kind of sad that we couldn't finish the project as expected. I was really hoping to get it done! But we have tried our best and gave our all to try to come up with something in such short amount of time. If I can bring it back even one week earlier, I would definitely seek help from our TA and I'm sure I would be able to crack that problem. In general, I have no regrets, I've tried my best!

Responsibility: Yuxiao took over approximately 85% of the coding and debugging part. Ming also did a good job in setting up the hardware and assisting Yuxiao by providing probable solution to the problems we encountered. Respect to both of us :)