Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 29, 2024, 12:19:01 00:19


Login with username, password and session length


Pages: [1]
Print
Author Topic: 18F4550 USB interrupt on Proton V3?  (Read 8125 times)
0 Members and 1 Guest are viewing this topic.
Nele
Newbie
*
Offline Offline

Posts: 22

Thank You
-Given: 2
-Receive: 10


« on: January 29, 2008, 07:16:35 19:16 »

Hi,

Someone can help me?

I need to use an interrupt when i receive 8 bytes from PC application (in VB6) by USB on 18F4550 pic.

I am using a loop where i test if the data has arrived, but I need to use an interrupt.

How can I make it? Any examples?
Logged
robban
Senior Member
****
Offline Offline

Posts: 265

Thank You
-Given: 34
-Receive: 38


Warrior


WWW
« Reply #1 on: January 29, 2008, 07:45:49 19:45 »

' This is what I found in the gallery.  Use it or loose it... If I were You I just pick the Interrupt handler.
' It's written for the 16C765 using proton so You probably have to check Yr. 18F4550 Datasheet to port it.
' Program to demonstrate the USB commands with interrupt
' Moves the computer's cursor in a small square

Code:
Device = 16C765
        XTAL = 24

        USB_DESCRIPTOR = "MOUSDESC.ASM" ' Point to the DESCRIPTOR file, available in the proton IDE
        USB_CLASS_FILE = "HIDCLASS.ASM" ' Point to the CLASS file                   - same -
        USB_COUNT_ERRORS = False ' Enable/Disable error monitors
        USB_SHOW_ENUM = False ' Enable/Disable PORTB monitor
       

Dim BUFFER[8] as Byte
Dim LOOPCNT as Byte
Dim DIRECTION as Byte

        Symbol LED = PORTA.5 ' Red LED on PORTA bit 5

        Symbol USB_WRITE_ERROR = _USB_WRT_ERR.WORD
        Symbol USB_BTO_ERROR = _USB_BTO_ERR.WORD
        Symbol USB_OWN_ERROR = _USB_OWN_ERR.WORD
        Symbol USB_BTS_ERROR = _USB_BTS_ERR.WORD
        Symbol USB_DFN8_ERROR = _USB_DFN8_ERR.WORD
        Symbol USB_CRC16_ERROR = _USB_CRC16_ERR.WORD
        Symbol USB_CRC5_ERROR = _USB_CRC5_ERR.WORD
        Symbol USB_PID_ERROR = _USB_PID_ERR.WORD
       
' Define the hardware interrupt handler for the USB vector
ON_INTERRUPT Goto USBINT
       
'-----------------------------------------------------------------------------------
        Goto START              ' Jump over the interrupt handler
'-----------------------------------------------------------------------------------
' Assembly language interrupt handler
' to check interrupt source and vector to it
USBINT:                                                                          'edit use c o d e and smiles are gone :)
Movlw (Service@USBInt >> 8)               'I don't know why that smilie appears. It should be an eight!!!
        Movwf PCLATH ' Point PCLATH to the USB subroutines
Btfsc PIR1, USBIF ' Make sure it is a USB interrupt
Call (Service@USBInt)              ' Implement the USB subroutines
Context Restore ' Restore saved registers

'-----------------------------------------------------------------------------------
' *** THE MAIN PROGRAM LOOP STARTS HERE ***
START: ALL_DIGITAL = True ' Make PORTA, and PORTE all digital

        Low LED
        USBInit                  ' Initialise USB and wait until configured
High LED ' Turn on LED for USB ready
STR BUFFER = 0,0,0,0,0,0,0,0 ' Clear the buffer array
' Move the computer's cursor in a small square
MOVECURSOR:
DIRECTION = 0
        Repeat
LOOPCNT = 0
            Repeat
If DIRECTION = 0 Then BUFFER#1 = 0 : BUFFER#2 = -2 : Goto SENDIT
            If DIRECTION = 1 Then BUFFER#1 = -2 : BUFFER#2 = 0 : Goto SENDIT
            If DIRECTION = 2 Then BUFFER#1 = 0 : BUFFER#2 = 2 : Goto SENDIT
            If DIRECTION = 3 Then BUFFER#1 = 2 : BUFFER#2 = 0

SENDIT: USBOut 1, BUFFER, 4, SENDIT  ' Send BUFFER to endpoint 1
Inc LOOPCNT
                                      Until LOOPCNT = 16 ' 16 steps in each direction
            Inc DIRECTION
            Until DIRECTION = 4
Goto MOVECURSOR              ' Do it forever
« Last Edit: June 11, 2008, 08:50:53 20:50 by pickit2 » Logged

Code Warrior
Nele
Newbie
*
Offline Offline

Posts: 22

Thank You
-Given: 2
-Receive: 10


« Reply #2 on: January 29, 2008, 08:01:17 20:01 »

Hi robban,

Thanks for your response.

That example is similar as i saw in Proton examples, mi pic isnĀ“t the same as you know.

That is my problem, I need an example for 18F4550.

Thanks.
Logged
robban
Senior Member
****
Offline Offline

Posts: 265

Thank You
-Given: 34
-Receive: 38


Warrior


WWW
« Reply #3 on: January 29, 2008, 09:07:33 21:07 »

Well, I don't have any include file for the 18F4550 in my old crownhill compiler, but You should be able to fix one for Yourself, otherwise it's useless anyway. If You find one, You have all the necessary register-, banks and opcodes there to port it. Assembly is not affected at all anyhow...
Logged

Code Warrior
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC