P.1
Embedded Software Autumn 2016
Project – Memory Game
Random number generator. Touch sense input. Debouncing. Memory game.
Introduction
Random number generation is important in many applications, such as cryptography, engineering simulations (e.g Monte Carlo analysis), and gaming. A pseudorandom number generator is an algorithm for generating a sequence of numbers whose statistical properties approximate real sequences of random numbers. However, the generated sequence is not truly random, because it is completely determined by a relatively small set of initial values, and the generated sequence is periodic. The K70 has a Random Number Generator hardware module which introduces true randomness into the generation of a sequence of 32-bit numbers. Refer to Chapter 37 of Freescale’s K70 Sub-Family Reference Manual for more information.
Capacitive touch sensing has become one of the de-facto technologies for user input in a Human-Machine Interface (HMI). The K70’s Touch Sense Input (TSI) module is able to drive touch sensing electrodes (or capacitors, created by flat conductive areas) and has logic that automatically scans, measures and outputs the results, and generates interrupt signals to the CPU. Refer to Chapter 60 of Freescale’s K70 Sub-Family Reference Manual for more information.
Debouncing is necessary for all styles of pushbuttons, switches and TSIs due to mechanical and electrical noise. A simple way to debounce an input in software is to accumulate a number of consecutive stable values.
Objectives
1. To generate random numbers.
2. To implement a touch sensitive interface.
3. To debounce switch operations.
4. To create a real-time, reactive and multi-threaded application.
P.2
Embedded Software Autumn 2016
Equipment
1 TWR-K70F120M-KIT – UTS
1 USB cable – UTS
Freescale Kinetis Design Studio
Safety
This is a Category A laboratory experiment. Please adhere to the Category A
safety guidelines (issued separately).
Cat. A lab
P.3
Embedded Software Autumn 2016
Software Requirements
1. A hardware abstraction layer (HAL) is to be written for the random number generator (RNG). The HAL should support initialization of the RNG and the generation of 32-bit random numbers.
2. A hardware abstraction layer (HAL) is to be written for the Touch Sense Input (TSI) module. The HAL should support the setting up of the TSI module, self-calibration, “baseline tracking” and interrupts. Refer to the Tower schematics ([login to view URL]) to determine how the electrodes, which surround the LEDs, have been set up, and to determine appropriate ports and pins to manipulate on the K70.
The following parameters should be used for setting up the TSI module:
Parameter
Value
Number of Consecutive Scans Per Electrode
10
Electrode Oscillator Prescaler
4
Ref OSC Charge Current
32 μA
External OSC Charge Current
18 μA
Scan Period Modulus
10
Active Mode Clock Source
LPO
Active Mode Prescaler Divider Value
2
Note: There is a mask set erratum “e2638: TSI: The counter registers are not immediately updated after the EOSF bit is set” available for you to read in KINETIS_4N96B.pdf. This is a hardware fault and you will have to implement the workaround.
3. A general debounce module should be written that can debounce any type of digital input (TSI, pushbutton, switch, etc.). It should be used to debounce the TSI.
P.4
Embedded Software Autumn 2016
4. In the main program, three different modes of using the TSI are required:
Default: The LEDs behave as they did in Lab 5.
Touch Toggle: If SW1 is pressed the program should enter a mode where a touch of a TSI electrode toggles the corresponding LED. The LEDs should initially be off. If no touch input has occurred for 5 seconds, the mode returns to the default.
Memory Game: If SW2 is pressed the program should enter a mode where it mimics the popular Simon game. In this game, the Tower will flash (for 1 second) a random sequence of LEDs, starting with a length of one. It then waits for the user to touch the corresponding LEDs (i.e. the corresponding TSI electrodes) in sequence (within 2 seconds for each LED). If the user is successful, it will add an additional random LED to the sequence, up to a limit of length 32. If an incorrect sequence is input by the user, or they take too long, or they reach a sequence length of 32, all the LEDS will blink rapidly and the game will reset (after 2 seconds). You are to record the high score (the number of LEDs in the sequence when the game ends) in Flash memory. The high score will then be available for interrogation via the TowerPC interface. If a game ends after the first LED, due only to the absence of a touch after 2 seconds, the main program returns to the default mode.
5. No header files have been specified – it’s time to make your own!
6. Extra commands of the Tower serial protocol to be implemented are:
Tower to PC
PC to Tower
0x0E Game – High Score
0x0E Game – High Score
7. TortoiseSVN must be used for version control.
Dear You,
I am really interested to work on this project,
I can start the work now , and can provide the best services from my end.
Please come on chat to discuss more about the project.
Thanks!
Hey,
In your project description, I observe that it needs an expertise in embedded domain to implement this.
It can be implemented in C or C++ depending upon your requirement(that is not mentioned in the project description). It also needs an system level understanding of touch screen, debouncing and sensors working. I have already worked on a project of this kind and for that i have used TI's Beaglebone and MSP430 32 bit.
Also i think if you can ping me, we can better discuss on this since project needs some more clarification.
I will definitely provide an optimised solution to your problem.
I hope you consider my bid.
Regards,
Hemanth