Quantcast
Viewing all articles
Browse latest Browse all 4867

General • Problen with interrupt in assembly riscv on pico2

I'm trying to program a usb connection in riscv assembler on the pico2 starting from the example dev_lowlevel.c and of course without using the SDK.

In this example, we don't see where the interrupt management function is called so I dived into the documentation chapter 3.8.4 and examined the assembler generated for this example.
In my program, I put the function irq_set_enabled with the parameter = 14 (IRQ USB)
I created a table __VECTOR_TABLE in .data aligned on 64 bits and which contains:

Code:

__VECTOR_TABLE:    j arret10Eclats    .skip 8    j arret10Eclats    .skip 12    j arret10Eclats    .skip 12    j arret10Eclats    #j isr_riscv_machine_external_irq 
Following the function:
isr_riscv_machine_external_irq: identical to that found in the example

I put the address of this table +1 in the register mtvec and set the bits in the registers mstatus, MIE and MIP with the values ​​below :

Code:

   laa0,__VECTOR_TABLE  + 1         # voir 3.8    csrwmtvec,a0    li t0,0b10001000    csrs 0x300,t0        # 1 dans MSTATUS.MIE    li t0,0b100000000000    csrs 0x344,t0        # 1 bit MEIP MIP Register    csrs 0x304,t0        # 1 bit MEIP MIE Register
I also created a 32-bit aligned __soft_vector_table whose position (14 * 4) contains the address of my interrupt handling function.

But the isr_riscv_machine_external_irq function never seems to be called when I plug the pico into my computer's USB port. W11 tells me that the device has malfunctioned!!

I must have forgotten something but what?

Statistics: Posted by VincentARM — Sun Jan 19, 2025 8:53 pm



Viewing all articles
Browse latest Browse all 4867

Trending Articles