/* Lab-specific initialization goes here */
void labinit( void )
{
  * portE = 0x0; // for LED outputs
  // only for the last 8 bits
  * E = * E & 0xFF00;
  // initialising port D as input
  // using the pic32mx system
  TRISD = TRISD & 0x0FE0;

  PR2 = TMR2PERIOD;
  T2CON = 0x0; // clearing the clock
  T2CONSET = 0x70; // setting the prescale
  TMR2 = 0; // reset timer to 0
  T2CONSET = 0x8000; // turn timer on, set bit 15 to 1


  // configuring the priority level
  IPC(2) = 7;
  // enabling bit 8 for the interupt
  IEC(0) = 0x100;

  // configuring the priority
  IPC(1) = 0x1C000000 ;
  // enabling bit 7 fot interrupt
  IEC(0) = IEC(0) | 0x80;


  // calling interupt from labwork.S
  enable_interrupt();
  
  return;
}
Пример #2
0
/* Lab-specific initialization goes here */
void labinit( void )
{
    volatile int* trise = (volatile int*) 0xbf886100;
    *trise = *trise & 0xff00;
    TRISD = TRISD | 0x0fe0;

    //initialize timer 2
    T2CON = 0x70; //sätt 1:256 prescale !!! bit 5-4 ska vara 11, bit 6 oklar
    //men den måste vara 1
    PR2 = (80000000/256)/10; //sätt perioden till en tiondel av en sekund
    PR2 = PR2*2; // <------- surprise assignment
    TMR2 = 0; //reseting counter for timer 2
    T2CONSET = 0x8000; // start timer (ON bit is bit 15)

    //enable interrupts
    IEC(0) = IEC(0) | 0x0100; //sätt bit 8 till 1 för att enable interrupts

    IPC(2) = 7; //ta emot interrupts från Timer 2, högsta prioritet
    //7 är högsta med 3 bitar

    enable_interrupts(); //kalla assembler metod för att enabla globala interrupts


    return;
}
/* Lab-specific initialization goes here */
void labinit( void )
{
  // defining the int pointer, trise, volatile because you 
  //don't want the c compiler to optimise
  volatile int * E = (volatile int *) 0xbf886100;
  // 
  volatile int * portE = (volatile int *) 0xbf886110;
  * portE = 0x0; // for LED outputs
  // only for the last 8 bits
  * E = * E & 0xFF00;
  // initialising port D as input
  // using the pic32mx system
  TRISD = TRISD & 0x0FE0;

  PR2 = TMR2PERIOD;
  T2CON = 0x0; // clearing the clock
  T2CONSET = 0x70; // setting the prescale
  TMR2 = 0; // reset timer to 0
  T2CONSET = 0x8000; // turn timer on, set bit 15 to 1

  // enabling interupts from Timer 2
  // IPC(2) = 7;
  IPC(2) = IPC(2) | 0x10;
  // set bit no 8 to enable interupt
  IEC(0) = 0x100;
  // calling interupt from labwork.S
  enable_interrupt();
  
  return;
}
Пример #4
0
/* initialization routine */
void init (void) {
  /* turn spi off and clear interrupts */
  SPI2CON = 0;
  IEC(1) = 0;
  IPC(7) = 0;
  IFS(1) = 0;

  /* set interrupts */
  IPC(7) = (7<<24);
  IEC(1) = (1<<7);

  /* set spi */
  SPI2BRG = 0x1FF;      // Set SCK ~78kHz
  SPI2STATCLR = 0x40;   // Clear SPIROV bit
  SPI2CON = 0x8060;     // Set ON, CKE = 0, CKP = 1, MSTEN = 1
  asm("ei");
}
Пример #5
0
/* This function is called before main() is called, you can do setup here */
void _on_bootstrap() {
	inputinit();
	display_init();
	IEC(0) = 0x100;			/* Interrupt Enable Control */
	IPC(2) = 0b111110100;		/* Interrupt Priority Control */
	TMR2 = 0;			/* Reset Timer Value */
	PR2 = 31250;			/* Set period register */
	T2CON = 0b1000000001110000;	/* Set internal 16-bit timer. Prescaling 1:256 */
	__asm__ volatile("ei");		/* Enable interrupt */	
	
}
Пример #6
0
void exit_game()
{
    IEC(0) = ~0xFFFF;
    display_string(0, "                ");
    display_string(1, "   Game Over    ");

    char str[16] = "  Score: ";
    char *scr = itoaconv(score);
    for(int i = 9; *scr; str[i] = *scr++, i++);
    display_string(2, str);

    display_update_text();
    for(;;);
}
Пример #7
0
/* Lab-specific initialization goes here */
void labinit( void )
{
  volatile int* trise = (volatile int*) 0xbf886100; // 8 sista satta till 0 (Output)
  TRISD = 0xfe0; // [11:5] Som input. Resten output
  
  PR2 = TIMER2PERIOD;
  TMR2 = 0;
  T2CON = 0x70; // Sätter prescale till 1:256
  
  IEC(0) = 0x100; // Sätter tmr2 interrupt enable
  IPC(2) = 0x4; // Sätter icke-noll prio till de tre bitarna.
  T2CONSET = 0x8000; // Startar timern
  enable_interrupt();
  return;
}
Пример #8
0
			/*
			 * load index for one file 
			 */
			static IndexEntryContainer::unique_ptr_type
				loadAccIndex(std::string const & filename)
			{
				uint64_t const indexpos = getIndexPos(filename);

				::libmaus::aio::CheckedInputStream indexistr(filename);
				// seek to index position
				indexistr.seekg(indexpos,std::ios::beg);
				// 
				::libmaus::bitio::StreamBitInputStream SBIS(indexistr);
				
				// read size of index
				uint64_t const numentries = ::libmaus::bitio::readElias2(SBIS);
				// pos bits
				unsigned int const posbits = ::libmaus::bitio::readElias2(SBIS);
				
				// k bits
				unsigned int const kbits = ::libmaus::bitio::readElias2(SBIS);
				// k acc
				/* uint64_t const symacc = */ ::libmaus::bitio::readElias2(SBIS);

				// v bits
				unsigned int const vbits = ::libmaus::bitio::readElias2(SBIS);
				// v acc
				/* uint64_t const symacc = */ ::libmaus::bitio::readElias2(SBIS);
				
				// align
				SBIS.flush();
				
				SBIS.getBitsRead();
				
				// std::cerr << "numentries " << numentries << std::endl;
				
				// read index
				libmaus::autoarray::AutoArray< IndexEntry > index(numentries+1,false);
				
				for ( uint64_t i = 0; i < numentries+1; ++i )
				{
					uint64_t const pos = SBIS.read(posbits);
					uint64_t const kcnt = SBIS.read(kbits);
					uint64_t const vcnt = SBIS.read(vbits);
					index[i] = IndexEntry(pos,kcnt,vcnt);
				}
				
				IndexEntryContainer::unique_ptr_type IEC(new IndexEntryContainer(index));
				
				return UNIQUE_PTR_MOVE(IEC);
			}