This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

EZ-USB Autovectoring problem with MON51

Hi,

I've encountered a problem trying to implement autovectoring with an EZ-USB Development Board (AN2131-DK001) using the Keil evaluation DK51. I've scoured the net to see if anyone else has encountered the same problem, but to no avail.

I have the following code in an .a51 file.


CSEG	AT 43H
equ	$ + 2
DB	02H
DB	HIGH 4100h
DS	1


I found the above code here on the Keil site.

I then have the following code in a C file.


#pragma intvector (0x40FD) //start at 4100h
#pragma interval (4)

void Sudav_ISR (void) interrupt 0
{
}

.
.
.


In the above code I define all 21 EZ-USB interrupts.

Result: When using the MON51 for debugging purposes, at address 43h in the disassembly there is a an LJMP 4108h (would have expected it to be LJMP 4100 - off by 8).

In the disassembly starting at location 4100 is an LJMP to my first interrupt, Sudav_ISR. The following 20 interrupts defined in my code SHOULD follow at intervals of four. This doesn't happen. Some of the interrupts don't even show up, lest at intervals of 4.

When disassembled using just the simulator as a debugger, the code looks perfect.

Thanks for any insight and help =)

Natisha

Parents
  • 1) It is true that byte@45 "is automatically modified by the EZ-USB hardware and is therefore not writeable".

    2 ) The DS instruction is the correct choice. I was just pointing out that there was no basis for Byte@45 == 0.

    3 ) I have not tried your method. I have used:

    #pragma NOIV // Do not generate interrupt vectors
    
    void ISR_Sof( void ) interrupt 0
    {
    	EZUSB_IRQ_CLEAR(); //do 1st
    	USBIRQ = bmSOF;   //Clear SOF IRQ
    
      ++mUsbFrame;
    }
    

    NAME		USBJmpTbl
    
    extrn		code (ISR_Sudav, ISR_Sof, ISR_Sutok, ISR_Susp, ISR_Ures, ISR_IBN, ISR_Ep0in, ISR_Ep0out, ISR_Ep1in, ISR_Ep1out, ISR_Ep2in, ISR_Ep2out, ISR_Ep3in, ISR_Ep3out, ISR_Ep4in, ISR_Ep4out, ISR_Ep5in, ISR_Ep5out, ISR_Ep6in, ISR_Ep6out, ISR_Ep7in, ISR_Ep7out)
    public		USB_AutoVector, USB_Jump_Table
    ;------------------------------------------------------------------------------
    ; Interrupt Vectors
    ;------------------------------------------------------------------------------
    		CSEG	AT 43H
    USB_AutoVector	equ	$ + 2
    		ljmp	USB_Jump_Table	; Autovector will replace byte 45
    ;------------------------------------------------------------------------------
    ; USB Jump Table
    ;------------------------------------------------------------------------------
    ?PR?USB_JUMP_TABLE?USBJT	segment	code page	; Place jump table on a page boundary
    		RSEG 	?PR?USB_JUMP_TABLE?USBJT	; autovector jump table
    USB_Jump_Table:	
    		ljmp	ISR_Sudav	; Setup Data Available
    		db	0		
    		ljmp	ISR_Sof	; Start of Frame
    		db	0
    		ljmp	ISR_Sutok	; Setup Data Loading
    		db	0
    		ljmp	ISR_Susp	; Global Suspend
    		db 	0
    		ljmp	ISR_Ures	; USB Reset  	
    		db	0
    		ljmp	ISR_IBN	    ; IN Bulk NAK interrupt
    		db	0
    		ljmp	ISR_Ep0in	; End Point 0 In
    		db	0
    		ljmp	ISR_Ep0out	; End Point 0 Out
    		db	0
    		ljmp	ISR_Ep1in	; End Point 1 In
    		db	0
    		ljmp	ISR_Ep1out	; End Point 1 Out
    		db	0
    		ljmp	ISR_Ep2in
    		db	0
    		ljmp	ISR_Ep2out
    		db	0
    		ljmp	ISR_Ep3in
    		db	0
    		ljmp	ISR_Ep3out
    		db	0
    		ljmp	ISR_Ep4in
    		db	0
    		ljmp	ISR_Ep4out
    		db	0
    		ljmp	ISR_Ep5in
    		db	0
    		ljmp	ISR_Ep5out
    		db	0
    		ljmp	ISR_Ep6in
    		db	0
    		ljmp	ISR_Ep6out
    		db	0
    		ljmp	ISR_Ep7in
    		db	0
    		ljmp	ISR_Ep7out
    		db	0
    ;
    		end



Reply
  • 1) It is true that byte@45 "is automatically modified by the EZ-USB hardware and is therefore not writeable".

    2 ) The DS instruction is the correct choice. I was just pointing out that there was no basis for Byte@45 == 0.

    3 ) I have not tried your method. I have used:

    #pragma NOIV // Do not generate interrupt vectors
    
    void ISR_Sof( void ) interrupt 0
    {
    	EZUSB_IRQ_CLEAR(); //do 1st
    	USBIRQ = bmSOF;   //Clear SOF IRQ
    
      ++mUsbFrame;
    }
    

    NAME		USBJmpTbl
    
    extrn		code (ISR_Sudav, ISR_Sof, ISR_Sutok, ISR_Susp, ISR_Ures, ISR_IBN, ISR_Ep0in, ISR_Ep0out, ISR_Ep1in, ISR_Ep1out, ISR_Ep2in, ISR_Ep2out, ISR_Ep3in, ISR_Ep3out, ISR_Ep4in, ISR_Ep4out, ISR_Ep5in, ISR_Ep5out, ISR_Ep6in, ISR_Ep6out, ISR_Ep7in, ISR_Ep7out)
    public		USB_AutoVector, USB_Jump_Table
    ;------------------------------------------------------------------------------
    ; Interrupt Vectors
    ;------------------------------------------------------------------------------
    		CSEG	AT 43H
    USB_AutoVector	equ	$ + 2
    		ljmp	USB_Jump_Table	; Autovector will replace byte 45
    ;------------------------------------------------------------------------------
    ; USB Jump Table
    ;------------------------------------------------------------------------------
    ?PR?USB_JUMP_TABLE?USBJT	segment	code page	; Place jump table on a page boundary
    		RSEG 	?PR?USB_JUMP_TABLE?USBJT	; autovector jump table
    USB_Jump_Table:	
    		ljmp	ISR_Sudav	; Setup Data Available
    		db	0		
    		ljmp	ISR_Sof	; Start of Frame
    		db	0
    		ljmp	ISR_Sutok	; Setup Data Loading
    		db	0
    		ljmp	ISR_Susp	; Global Suspend
    		db 	0
    		ljmp	ISR_Ures	; USB Reset  	
    		db	0
    		ljmp	ISR_IBN	    ; IN Bulk NAK interrupt
    		db	0
    		ljmp	ISR_Ep0in	; End Point 0 In
    		db	0
    		ljmp	ISR_Ep0out	; End Point 0 Out
    		db	0
    		ljmp	ISR_Ep1in	; End Point 1 In
    		db	0
    		ljmp	ISR_Ep1out	; End Point 1 Out
    		db	0
    		ljmp	ISR_Ep2in
    		db	0
    		ljmp	ISR_Ep2out
    		db	0
    		ljmp	ISR_Ep3in
    		db	0
    		ljmp	ISR_Ep3out
    		db	0
    		ljmp	ISR_Ep4in
    		db	0
    		ljmp	ISR_Ep4out
    		db	0
    		ljmp	ISR_Ep5in
    		db	0
    		ljmp	ISR_Ep5out
    		db	0
    		ljmp	ISR_Ep6in
    		db	0
    		ljmp	ISR_Ep6out
    		db	0
    		ljmp	ISR_Ep7in
    		db	0
    		ljmp	ISR_Ep7out
    		db	0
    ;
    		end



Children
  • LOL. I got fed up trying to set up the jump table in C soooo I decided to code it in Assembly instead. (How I orginally had it)

    I've tried using the EXACT code same code that you're using (that code is floating around on the Keil Site) and yet the MON51 does NOT like the LJMP USB_Jump_Table instruction since it attempts to write code at location 45h.

    The kicker is, that I have disabled ALL of my interrupts EXCEPT for the Suspend interrupt. Unless I'm missing something, there should be no reason for the offset of 8 since the AVEC/IVEC register is 0 by default on reset and since I have not enabled the SUTOK interrupt.

    Also interesting, when I disable the autovectoring (AVEN = 0) even then, a LJMP 4100H will turn into LJMP 4108H when using the MON51 debugger.

    Btw, thanks for your help thus far =)