OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [bootloader/] [bootloader.c] - Diff between revs 13 and 14

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 13 Rev 14
Line 174... Line 174...
  MTIME_LO = 0;
  MTIME_LO = 0;
  MTIME_HI = 0;
  MTIME_HI = 0;
 
 
  // deactivate unused IO devices
  // deactivate unused IO devices
  neorv32_wdt_disable();
  neorv32_wdt_disable();
  neorv32_clic_disable();
 
  neorv32_pwm_disable();
  neorv32_pwm_disable();
  neorv32_spi_disable();
  neorv32_spi_disable();
  neorv32_trng_disable();
  neorv32_trng_disable();
  neorv32_twi_disable();
  neorv32_twi_disable();
 
 
Line 336... Line 335...
 
 
  // wait for UART to finish transmitting
  // wait for UART to finish transmitting
  while ((UART_CT & (1<<UART_CT_TX_BUSY)) != 0);
  while ((UART_CT & (1<<UART_CT_TX_BUSY)) != 0);
 
 
  // reset performance counters (to benchmark actual application)
  // reset performance counters (to benchmark actual application)
  asm volatile ("csrrw zero, mcycle,    zero"); // will also clear 'cycle'
  asm volatile ("csrw mcycle,    zero"); // will also clear 'cycle'
  asm volatile ("csrrw zero, mcycleh,   zero"); // will also clear 'cycleh'
  asm volatile ("csrw mcycleh,   zero"); // will also clear 'cycleh'
  asm volatile ("csrrw zero, minstret,  zero"); // will also clear 'instret'
  asm volatile ("csrw minstret,  zero"); // will also clear 'instret'
  asm volatile ("csrrw zero, minstreth, zero"); // will also clear 'instreth'
  asm volatile ("csrw minstreth, zero"); // will also clear 'instreth'
 
 
  // start app at instruction space base address
  // start app at instruction space base address
  while (1) {
 
    register uint32_t app_base = SYSINFO_ISPACE_BASE;
    register uint32_t app_base = SYSINFO_ISPACE_BASE;
    asm volatile ("jalr zero, %0" : : "r" (app_base));
    asm volatile ("jalr zero, %0" : : "r" (app_base));
  }
  while (1);
}
}
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**
 * Machine system timer (MTIME) interrupt handler.
 * Machine system timer (MTIME) interrupt handler.
Line 357... Line 355...
 **************************************************************************/
 **************************************************************************/
void __attribute__((__interrupt__)) mtime_irq_handler(void) {
void __attribute__((__interrupt__)) mtime_irq_handler(void) {
 
 
  // make sure this was caused by MTIME IRQ
  // make sure this was caused by MTIME IRQ
  uint32_t cause = neorv32_cpu_csr_read(CSR_MCAUSE);
  uint32_t cause = neorv32_cpu_csr_read(CSR_MCAUSE);
  if (cause != EXCCODE_MTI) { // raw exception code for MTI
  if (cause != TRAP_CODE_MTI) { // raw exception code for MTI
    neorv32_uart_print("\n\nEXCEPTION: ");
    neorv32_uart_print("\n\nEXCEPTION: ");
    print_hex_word(cause);
    print_hex_word(cause);
    neorv32_uart_print(" @ 0x");
    neorv32_uart_print(" @ 0x");
    print_hex_word(neorv32_cpu_csr_read(CSR_MEPC));
    print_hex_word(neorv32_cpu_csr_read(CSR_MEPC));
    system_error(ERROR_SYSTEM);
    system_error(ERROR_SYSTEM);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.