Académique Documents
Professionnel Documents
Culture Documents
I. INTRODUCTION
Todays smart devices industry is expanding rapidly.
Initially, the smartphone was the device that initiated the
effort to make everyday devices smarter by integrating
microcontroller electronics, user interactivity and internet
connectivity. A new effort in the industry is to create a smart
watch, expanding greatly on the traditional wrist watch that
did little more than tell time. Smart watches include fitness
tracking, text and call capability, emails, navigation, and
internet enabled services. A basic smart-watch style device
would include simple implementations of such a system.
In this project, a basic smart-watch type embedded
device is designed with basic multimedia and interactive
features. A Cortex M4 SoC is used to interface with many
peripherals to realize the feature list. The multimedia device
had a few basic apps including a basic version of a classic
video game Space Invaders, and a weather monitoring
application is also implemented that displays basic ambient
weather information. These programs are selectable to run
on the device screen by the user. The device has been
designed to be expandable in terms of its functionality to
include an image gallery, compass, and possibly other
applications.
The hardware components used is the Texas
Instruments TM4C123GXL development board with a
Cortex M4F SoC, a Sensor hub add-on also by Texas
Instruments, a 1.8 Adafruit LCD screen, and a generic slidepotentiometer.
1.
3.
Image Gallery:
The simple image gallery displayed saved images
from system memory. These images can be scrolled
through using the pushbuttons. Left scrolling by left
pushbutton and right scroll by right pushbutton. This
}
// ********************** Images **********************
const uint16_t Missile0[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFFF,
0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0xFFFF, 0x0000, 0x0000,
0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0x0000, 0x0000,
0x0000, 0xFFFF, 0x0000,
};
// other images for onscreen instances are described similarly
//
// ************GAME ENGINE INIT AND ROUTINES************
// This sections controls motion of sprite and aliens
// Above defined images will be manipulated here
void EnemyInit(void){
// the enemy character draw generated here
}
void SpriteInit(void){
// the player gunship routines here
}
void fireMissile (){
// missile fire routine here
}
// similar routines for Laser fire
void detectCollision (){
// detect collision between fire and enemy here
}
void SysTick_Handler(void){
//main game engine is run here at every interrupt
// all functions are initialized and called here
}
//**************LCD OUTPUT ROUTINE*****************
// the player gunship, aliens and missles/laser are all drawn using this
routine
// function calls made to the LCD driver include
void Draw(void){
// routines for drawing all characters and images on screen
// routine for moving the characters on screen
}
//******************MAIN ROUTINE********************
int main(void){
// all routines initialized
//peripherals initialized
//SysTick initialized
while(1){
draw(); // the call to draw function here
Flag = 0; // clear Flag for interrupt
// game engine runs in interrupt routine
}
}
3117
0x400F.E100
16
15Oct
ADC
3114
0x4003.8020
13Dec
SS3
31-16
7-0
Name
MAXADCSPD
10Nov
08Sep
SS2
06-Jul
SYSCTL_RCGC0_R
04May
SS1
02-Mar
1-0
SS0
ADC0_SSPRI_R
ADC0_EMUX_R
15-Dec
EM3
08-Nov
EM2
04-Jul
EM1
3-0
EM0
0x4003.8000
ASEN3
ASEN2
ASEN1
ASEN0
0x4003.80A0
MUX0
0x4003.80A4
TS0
IE0
END0
D0
ADC0_SSCTL3_R
0x4003.8028
SS3
SS2
SS1
SS0
ADC0_PSSI_R
0x4003.8004
INR3
INR2
INR1
INR0
ADC0_RIS_R
0x4003.800C
IN3
IN2
IN1
IN0
ADC0_ISC_R
0x4003.8014
Apr-31
31-Dec
0x4003.80A8
11-0
DATA
ADC0_ACTSS_R
ADC0_SSMUX3_R
ADC0_SSFIFO3
//****************ADCInitialize**********************
void ADC0_Init(void){ unsigned long volatile delay;
SYSCTL_RCGC2_R |= 0x00000010;
// 1) activate clock for
Port E
delay = SYSCTL_RCGC2_R;
// allow time for clock
to stabilize
GPIO_PORTE_DIR_R &= ~0x10;
// 2) make PE4 input
GPIO_PORTE_AFSEL_R |= 0x10;
// 3) enable alternate
function on PE4
GPIO_PORTE_DEN_R &= ~0x10; // 4) disable digital I/O
on PE4
GPIO_PORTE_AMSEL_R |= 0x10;
// 5) enable analog
function on PE4
SYSCTL_RCGC0_R |= 0x00010000;
// 6) activate ADC0
delay = SYSCTL_RCGC2_R;
SYSCTL_RCGC0_R &= ~0x00000300; // 7) configure for 125K
ADC0_SSPRI_R = 0x0123;
// 8) Sequencer 3 is
highest priority
ADC0_ACTSS_R &= ~0x0008;
// 9) disable sample
sequencer 3
ADC0_EMUX_R &= ~0xF000;
// 10) seq3 is software
trigger
ADC0_SSMUX3_R &= ~0x000F;
// 11) clear SS3 field
ADC0_SSMUX3_R += 9;
// set channel Ain9 (PE4)
ADC0_SSCTL3_R = 0x0006;
// 12) no TS0 D0, yes IE0
END0
ADC0_ACTSS_R |= 0x0008;
// 13) enable sample sequencer
3
}
//***********************ADC0_In*******************
// Slide-Pot inputs to ADC
// Busy-wait Analog to digital conversion
// Input: none
// Output: 12-bit result of ADC conversion
unsigned long ADC0_In(void){
unsigned long volatile result;
ADC0_PSSI_R = 0x0008;
// 1) initiate SS3
while((ADC0_RIS_R&0x08)==0){}; // 2) wait for conversion done
result = ADC0_SSFIFO3_R&0xFFF; // 3) read result
ADC0_ISC_R = 0x0008;
// 4) acknowledge completion
return result;
}
//******************Convert ADC input*****************
// Convert a 12-bit binary ADC sample into a 32-bit unsigned
// fixed-point distance (resolution 0.001).
// Input: sampled 12-bit ADC sample
// Output: 32-bit distance (resolution 0.001)
unsigned long Convert(unsigned long sample){
unsigned long volatile result;
//shift by 10 (divide by 2^10, multiply by 16 to get 0 to 64
position on screen
result = ((30*sample)>>10);
return result;
}
3124
2317
16
15Mar
Name
$E000E010
COUNT
CLK_SRC
INTEN
ENABLE
NVIC_ST_CTRL_R
$E000E014
NVIC_ST_RELOAD_R
$E000E018
NVIC_ST_CURRENT_R
31-29
2824
23-21
20Aug
05-Jul
40
Name
$E000ED20
TICK
PENDSV
DEBUG
NVIC_SYS_PRI3_R
//*****************SysTick Initialization******************
//Initialize SysTick power inturrepts for reading slit pot
// Initialize SysTick interrupts to trigger at 30 Hz, 33.33 ms
void SysTick_Init(unsigned long period){
NVIC_ST_CTRL_R = 0;
// disable SysTick during setup
NVIC_ST_RELOAD_R = period;
// reload value for 25ms (at PLL
80MHz)
NVIC_ST_CURRENT_R = 0;
// any write to current clears it
NVIC_SYS_PRI3_R = NVIC_SYS_PRI3_R&0x00FFFFFF; // priority 0
NVIC_ST_CTRL_R = 0x00000007; // enable with core clock and
interrupts
EnableInterrupts();
}
// ***********SysTick Handler to run game engine***********
// ISR handler for SysTick interrupt
// executes every 33.33 ms, collects a sample, converts, moved
gunship, and sets flag for main.
void SysTick_Handler(void){
//main game engine is run here at every interrupt
// all functions are initialized and called here
ADCdata = ADC0_In(); //read ADC
Distance = Convert(ADCdata); //convert to distance for
player
Sptrite.x = Distance; //player position onscreen
If (buttonMissile == 0){ //read button for missile
MissileInit();
PortFLED = 0x02 //Green LED on
}
B.
0x41
0x77
0x40
// I2C interrupt handler for the sensors. I2C3 interface used on the
TM4C SoC
void TMP006I2CIntHandler(void)
{
//data read sequence for TMP006
}
void BMP180I2CIntHandler(void)
{
//data read sequence for BMP180
}
Void SHT21I2CIntHandler(void)
{
//data read sequence for SHT21
}
while(1)
{
// data flag reset routine
g_vui8DataFlagTMP006 = 0;
//read measurements for temperature
//read measurements for pressure
//read measurements for humidity
//convert float numbers to integer and decimal parts for display
i32IntegerPartBMP180 = (int32_t) fMeasurement;
i32FractionPartBMP180 =(int32_t) (fMeasurement * 1000.0f);
i32FractionPartBMP180=i32FractionPartMeasurement(i32IntegerPartMeasurement * 1000);
}
}