Advertisement
Felanpro

miposlabwork.c

Feb 21st, 2022
1,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.73 KB | None | 0 0
  1. /* mipslabwork.c
  2.  
  3.    This file written 2015 by F Lundevall
  4.    Updated 2017-04-21 by F Lundevall
  5.  
  6.    This file should be changed by YOU! So you must
  7.    add comment(s) here with your name(s) and date(s):
  8.  
  9.    This file modified 2017-04-31 by Ture Teknolog
  10.  
  11.    For copyright and licensing, see file COPYING */
  12.  
  13. #include <stdint.h>   /* Declarations of uint_32 and the like */
  14. #include <pic32mx.h>  /* Declarations of system-specific addresses etc */
  15. #include "mipslab.h"  /* Declarations for these labs */
  16. //#include "time4io.c"
  17.  
  18. int mytime = 0x5957;
  19.  
  20. char textstring[] = "text, more text, and even more text!";
  21.  
  22. /* Interrupt Service Routine */
  23. void user_isr( void )
  24. {
  25.   return;
  26. }
  27.  
  28. volatile int* porte = (volatile int*) 0xbf886110; //Port E is used for the LED
  29. int n = 0x0;
  30.  
  31. /* Lab-specific initialization goes here */
  32. void labinit( void )
  33. {
  34.     volatile int* trise = (volatile int*) 0xbf886100; //Tris E is used for configuration output = 0, input = 1 of the LED lights
  35.     *trise &= ~0xf00; //Set bits 0 through 7 to 0 (output)
  36.  
  37.     TRISD |= 0xfe0;//Set bits 5 through 11 to input (1 = input) (1111 1110 0000) = 0xfe0
  38.     /*
  39.     if((getbtns() & 0x4) == 1) //If button 2 is pressed (0100 = 0x4)
  40.     {
  41.         printf("Hello");
  42.     }
  43.     else if((getbtns() & 0x2) == 1) //If button 3 is pressed (0010 = 0x2)
  44.     {
  45.  
  46.     }
  47.     else if((getbtns() & 0x1) == 1) //If button 4 is pressed (0001 = 0x1)
  48.     {
  49.  
  50.     }
  51.     */
  52.  
  53.     return;
  54. }
  55.  
  56. /* This function is called repetitively from the main program */
  57. void labwork( void )
  58. {
  59.     *porte = n; // 1 = ON, 0 = OFF The 8 least significant bits correspond to an LED
  60.     delay( 1000 );
  61.     time2string( textstring, mytime );
  62.     display_string( 3, textstring );
  63.     display_update();
  64.     tick( &mytime );
  65.     display_image(96, icon);
  66.     n += 0x1;
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement