231a-ag progressdec10

From CSclasswiki
Jump to: navigation, search

Progress Report (as of December 10)



#include <stdio.h>
#include <stdlib.h>
#include <time.h>

extern int asm_main( void );    // entry point of assembly                      
extern time_t currentTime;       // assembly storage for time                   

int* _getLocalTime( ) {
  return (int*) localtime( &currentTime );

int main() {
  srand( time( 0 ) );
  // call assembly program                                                      
  • So far, the driver.c program gets the local time, and generates a random number.

Assembly File

Turning the Buzzer On at a Set Time

        call    getTimeOfDay
        mov     eax, [tm_hour]
        cmp     eax, dword[hour]
        je      cmpMin
        call    cmpHour

        mov     eax, [tm_min]
        cmp     eax, dword[min]
        je      cmpSec
        call    cmpHour

        mov     eax, [tm_sec]
        cmp     eax, dword[sec]
        je      buzzerOn
        call    cmpHour

        mov     ebx, usb
        call    openFile
        mov     dword[handle], eax
        mov     ebx, [handle]
        mov     ecx, on
        mov     edx, onLen
        call    writeFile
        mov     ebx, dword[handle]
        call    closeFile
  • The variables "hour", "min" and "sec" have been preset in section.data. I used the ledOn program to help me code this.

Arduino Sketch

The Arduino sketch, as of now, is quite long (because it repeats and is pretty inefficient in how it's written). I haven't changed it yet, because it works, and I want everything to work before trying to make it super-efficient. Because it's so long, I've made a completely separate page for it.

And hey... the Arduino Sketch Works! (Mostly.)

Okay, I can't figure out a way to embed the YouTube video in here, so I'm going to link you directly to it. (If you notice, when I press the "6" key on the keypad, the LED corresponding to "6" and "9" both blink weirdly... I haven't figured out why this happens yet?)