The link you gave is bad and I could not quite figure out the thread you were looking at. And we do not have your code and configs....
But maybe this will help
http://www.picbasic.co.uk/forum/cont...USB-SD-LOGGING
The link you gave is bad and I could not quite figure out the thread you were looking at. And we do not have your code and configs....
But maybe this will help
http://www.picbasic.co.uk/forum/cont...USB-SD-LOGGING
Dave
Always wear safety glasses while programming.
Hi mackrackit,
Thanks for the reply. Sorry about the link. Let me try it again.
http://www.picbasic.co.uk/forum/show...4292#post94292
Well I see in your code that it is different than Darrel's original post. It has more
USBINIT and USBSERVICE statements.
My Code: (copied from the bad link)
-----------
PAUSE 100
USBINIT
USBSERVICE
UIE = $7F
UEIE = $9F
@ INT_ENABLE USB_INT
Your Code:
-------------
PAUSE 100
USBINIT
USBSERVICE
UIE = $7F
UEIE = $9F
PAUSE 500
USBINIT
USBSERVICE
@ INT_ENABLE USB_INT
USBSERVICE
That would be great if that's all it is. I will try it tonight and let you know.
If it doesn't work, I will post my code and configs.
Well I tried it at work with a 18F4458 and still couldn't get it to connect. I verified my hardware setup was good by loading the code with the timer interrupt and that works fine.
Here is my complete program:
Code:'*************************************************************************************** ' Title: USB CDC and DT_INTS Testing ' CPU: 18F4458 ' Clock: 20 MHz External Clock ' '**************************************************************************************** ASM __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L __CONFIG _CONFIG1H, _FOSC_ECPLLIO_EC_1H & _FCMEN_OFF_1H & _IESO_OFF_1H __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H __CONFIG _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_OFF_3H __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L ENDASM DEFINE OSC 48 DEFINE NO_CLRWDT 1 DEFINE USB_BUS_SENSE PORTD,3 INCLUDE "cdc_desc.bas" INCLUDE "DT_INTS-18.bas" '---[Interrupts List]--- ASM INT_LIST macro ;Source, Label, Type, ResetFlag? INT_Handler USB_INT, USBServiceISR, ASM, yes endm INT_CREATE ENDASM goto InitChip '----[Interrupt handler -- Service USB]-------------------------------------------------- ASM USBServiceISR: USBSERVICE INT_RETURN ENDASM '---[Initialize Chip]-------------------------------------------------------------------- InitChip: PAUSE 100 USBINIT USBSERVICE UIE = $7F UEIE = $9F PAUSE 500 USBINIT USBSERVICE @ INT_ENABLE USB_INT USBSERVICE PORTA = 0 PORTB = 0 PORTC = 0 PORTD = 0 PORTE = 0 'setup port i/o TRISA = %00000000 TRISB = %11111111 TRISC = %00110000 TRISD = %00001000 TRISE = %00000000 'all dig ADCON1 = %00001111 'enable port b pullups INTCON2.7 = 0 Main: goto Main end
Tachyon,
USBSERVICE is a PBP statement, not an ASM statement. So it can't be in an ASM/ENDASM block.
It must be like this ...Then add an underscore in the INT_Handler statement.Code:'----[Interrupt handler -- Service USB]-------------------------------------------------- USBServiceISR: USBSERVICE @ INT_RETURNYou can only have 1 USBINIT in your program.Code:'---[Interrupts List]--- ASM INT_LIST macro ;Source, Label, Type, ResetFlag? INT_Handler USB_INT, _USBServiceISR, ASM, yes endm INT_CREATE ENDASM
And there should never be a USBSERVICE after the interrupt has been enabled.
Interrupting a USBSERVICE to do a USBSERVICE can cause bad things to happen.
The following program works perfectly here on a LAB-XUSB with an 18F4550.Code:'---[Initialize Chip]-------------------------------------------------------------------- InitChip: PAUSE 100 USBINIT USBSERVICE UIE = $7F UEIE = $9F ; PAUSE 500 ; USBINIT ; USBSERVICE @ INT_ENABLE USB_INT ; USBSERVICEMake sure you have 0.1uF bypass capacitors from VDD to VSS.Code:'*************************************************************************************** ' Title: USB CDC and DT_INTS Testing ' CPU: 18F4458 ' Clock: 20 MHz External Clock ' '**************************************************************************************** ASM __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H ; __CONFIG _CONFIG1H, _FOSC_ECPLLIO_EC_1H & _FCMEN_OFF_1H & _IESO_OFF_1H __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H __CONFIG _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_OFF_3H __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L ENDASM DEFINE OSC 48 DEFINE NO_CLRWDT 1 DEFINE USB_BUS_SENSE PORTD,3 INCLUDE "cdc_desc.bas" INCLUDE "DT_INTS-18.bas" '---[Interrupts List]--- ASM INT_LIST macro ;Source, Label, Type, ResetFlag? INT_Handler USB_INT, _USBServiceISR, ASM, yes endm INT_CREATE ENDASM goto InitChip '----[Interrupt handler -- Service USB]-------------------------------------------------- USBServiceISR: USBSERVICE @ INT_RETURN '---[Initialize Chip]-------------------------------------------------------------------- InitChip: PAUSE 100 USBINIT USBSERVICE UIE = $7F UEIE = $9F @ INT_ENABLE USB_INT PORTA = 0 PORTB = 0 PORTC = 0 PORTD = 0 PORTE = 0 'setup port i/o TRISA = %00000000 TRISB = %11111111 TRISC = %00110000 TRISD = %00001000 TRISE = %00000000 'all dig ADCON1 = %00001111 'enable port b pullups INTCON2.7 = 0 Main: goto Main end
And some people say that you also need 0.1uF from the USB +5V to VSS, but I've never had to do that.
DT
Hello Darrel,
Sorry but that code is not connecting either. I copied everything over. And it compiles OK.
What is also concerning me is the version I have with the timer interrupt is also dropping the connection after about a half hour. This is after I shortened the interrupt time to 1.3ms. Should I shorten the time even more? Is it because its a USB 1.1 computer? I haven't seen
it drop the connection on a USB 2.0 computer yet.
I've tried all I could think of on the USB Interrupt version. I might have to give up on that one
for now and just focus on the timer interrupt version.
So I'll increase the size of cap on Vusb pin and see if that helps.
Do you think shortening the interrupt time will help?
Thank you for all your help.
Regards,
Mike
Just an update if anyone is interested. The PIC on the USB 2.0 computer is over 6 hours and
has not dropped its connection. The same PIC on the USB 1.1 computer could not hold its
connection for longer than 20 minutes or so.
I am using a timer interrupt (0.6ms) to execute the USBSERVICE routine. If I ever find an
answer why than I will post it back here.
As far as the USB interrupt using DT-INTS-18 v34 for CDC, I haven't a clue why it won't
connect for me. I know the interrupt is not happening at all. And I know my hardware
works with the timer interrupt. If I find what I'm missing than I'll post that also.
Mike
Eureka! Yes I'm that happy. I found the reason why the USB interrupt was not working.
It was the line I uncommented in the cdc_desc.bas file (#define USE_USB_BUS_SENSE_IO).
I read somewhere, don't remember where, when using self powered circuit one should
define a Vbus sense I/0 and uncomment the line above in the cdc_desc file. This is supposed to make the design more USB compliant. If the user unplugs the USB cable, the 3V reg. is turned off. I verified this with a meter and peeked how it is done in the assembly USBSERVICE routine.
I don't mind if the 3V reg. stays on in my design. I am using a power supply. But I guess
it might be a concern in a battery powered design.
I should have mentioned the uncommenting bit in my post. I ASSUMED....
Anyway, thanks Darrel for giving me my timer back.
This is fantastic -
Mike
Bookmarks