Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* mipslabwork.c
- This file written 2015 by F Lundevall
- Updated 2017-04-21 by F Lundevall
- This file should be changed by YOU! So you must
- add comment(s) here with your name(s) and date(s):
- This file modified 2017-04-31 by Ture Teknolog
- For copyright and licensing, see file COPYING */
- #include <stdint.h> /* Declarations of uint_32 and the like */
- #include <pic32mx.h> /* Declarations of system-specific addresses etc */
- #include "mipslab.h" /* Declarations for these labs */
- int mytime = 0x5957;
- char textstring[] = "text, more text, and even more text!";
- /* Interrupt Service Routine */
- void user_isr( void )
- {
- return;
- }
- volatile int* porte = (volatile int*) 0xbf886110; //Port E is used for the LED lights
- int n = 0;
- /* Lab-specific initialization goes here */
- void labinit( void )
- {
- volatile int* trise = (volatile int*) 0xbf886100; //Tris E is used for configuration output = 0, input = 1 of the LED lights
- *trise &= ~0xf00; //Set bits 0 through 7 to 0 (output)
- TRISD |= 0xfe0; //Set bits 5 through 11 to input (1 = input) (1111 1110 0000) = 0xfe0
- return;
- }
- /* This function is called repetitively from the main program */
- void labwork( void )
- {
- int buttonStatus = getbtns();
- int switchNumber = getsw();
- if(buttonStatus == 1) //If button 2 is pressed
- {
- mytime &= 0xff0f;
- mytime = ((switchNumber & 0x0f) << 4) | mytime;
- }
- else if(buttonStatus == 2) //If button 3 is pressed
- {
- mytime &= 0xf0ff;
- mytime = ((switchNumber & 0x0f) << 8) | mytime;
- }
- else if(buttonStatus == 4) //If button 4 is pressed
- {
- mytime &= 0x0fff;
- mytime = ((switchNumber & 0x0f) << 12) | mytime;
- }
- else
- *porte = n; // 1 = ON, 0 = OFF The 8 least significant bits correspond to an LED
- delay(1000);
- time2string( textstring, mytime );
- display_string( 3, textstring );
- display_update();
- tick( &mytime );
- display_image(96, icon);
- n += 0x1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement