I deleted your other post as there is no need to double post.
You may need to post your complete code also.
I deleted your other post as there is no need to double post.
You may need to post your complete code also.
Dave
Always wear safety glasses while programming.
Anytime you are using interrupts (other than ON INTERRUPT), it interrupts things.
USB_ASM_Service uses USB interrupts that happen quite frequently.
Software timed routines like SEROUT2, PAUSE, PULSIN/OUT etc. Will lose time that they don't know about.
When using interrupts, Hardware devices should be use instead of software commands.
Instead of SEROUT2, use HSEROUT with the USART.
PAUSE ... use a timer.
PULSIN ... use a CCP module.
COUNT ... use a Timer
There are still many PBP commands you can use without problems.
But, if if they require specific timing thru software, that timing will be disturbed.
DT
Hi Darrel,
I'm actually back on USB development, there is quite a bit of new stuffs! your USB_ASM_Service routine is very exciting.
If I understand correctly the timing issue will also "kill" I2CRead/Write, Shiftin/Shiftout, LCDout... There's hardware modules for SPI and I2C, even if they are not used by these instructions. However there's not much solution for driving the LCD.
Is the delay introduced by the interrupt that long? I mean, some processes does not require an extreme regularity of clocking/data signals, an intelligent LCD display should probably cope with this.
However I haven't been able to experiment with it yet... I have managed to compile and run successfully the DCD demo on a PIC18F13K50. Adding the USB_ASM_Service routine and commenting the USBService/USBInit in the demo makes the board unable to declare itself anymore.
I've also tried running both the interrupt and polled USB servicing to display the status of "PLUGGED" on a LED but nothing happens. The rest of the demo works fine though.
Any lead for this issue?
Thanks in advance for your time
Can you post the non-working code?However I haven't been able to experiment with it yet... I have managed to compile and run successfully the DCD demo on a PIC18F13K50. Adding the USB_ASM_Service routine and commenting the USBService/USBInit in the demo makes the board unable to declare itself anymore.
Dave
Always wear safety glasses while programming.
Yep sure!
It is a quick and dirty modification of the CDC demo. A RGB LED takes the color code sent on the USB port as a letter. The code works, but commenting USBInit, and both USBService kill it.Code:ASM CONFIG CPUDIV=NOCLKDIV ; CPU runing at full speed CONFIG USBDIV=OFF ; Low speed USB clock diviser disabled, not used here CONFIG FOSC=HS ; Use of High Speed crystal oscillator CONFIG PLLEN=ON ; Enable PLL multiplier, 12Mhz oscilator x 4 CONFIG PCLKEN=ON ; Primary clock source is enabled CONFIG FCMEN=OFF ; Failsafe clock off CONFIG IESO=OFF ; Oscillator switchover mode disabled CONFIG WDTEN=ON ; Watchdog timer on CONFIG WDTPS=512 ; Watchdog divider is 512 CONFIG MCLRE=OFF ; Disable MCLR pin, enable RC3 CONFIG STVREN=ON ; Stack full/underflow will cause reset CONFIG LVP=OFF ; Low voltage programming disabled CONFIG BBSIZ=OFF ; 512kW block boot size CONFIG XINST=OFF ; Extended instruction mode disabled ENDASM Include "cdc_desc.bas" ' Include the CDC descriptors INCLUDE "USB_ASM_Service.pbp" ' USB Init and Service interrupt routines 'Define pin function TRISA = %00000000 'PortA all digital output TRISB = %00000000 'PortB all digital output TRISC = %00000000 'PortC all digital output ANSEL = %00000000 'Disable analog input on other pins ANSELH = %00000000 'Disable analog input on other pins 'Define weak pullups WPUA = %00000000 'No weak pullup on portA WPUB = %00000000 'No weak pullup on portB Define OSC 48 buffer VAR BYTE[16] cnt VAR BYTE Byte i VAR BYTE 'Pin function declaration GreenLED VAR PORTC.6 RedLED VAR PORTC.3 BlueLED VAR PORTC.4 pwmvalue VAR BYTE 'Program start pwmvalue = 130 HPWM 1,pwmvalue,32767 LOW REDLED LOW BLUELED LOW GREENLED Pause 10 USBInit ' Get USB going ' Wait for USB input idleloop: USBService ' Must service USB regularly cnt = 16 ' Specify input buffer size USBIn 3, buffer, cnt, idleloop i = 0 SELECT CASE buffer CASE "R" HIGH REDLED LOW GREENLED LOW BLUELED CASE "G" LOW REDLED HIGH GREENLED LOW BLUELED CASE "B" LOW REDLED LOW GREENLED HIGH BLUELED CASE "C" LOW REDLED HIGH GREENLED HIGH BLUELED CASE "M" HIGH REDLED LOW GREENLED HIGH BLUELED CASE "Y" HIGH REDLED HIGH GREENLED LOW BLUELED CASE "W" HIGH REDLED HIGH GREENLED HIGH BLUELED CASE "K" LOW REDLED LOW GREENLED LOW BLUELED CASE ELSE i = 1 END SELECT ' Message received IF i = 0 THEN buffer[0] = buffer buffer[1] = "-" buffer[2] = "O" buffer[3] = "k" buffer[4] = 13 buffer[5] = 10 buffer[6] = 0 ELSE buffer[0] = "E" buffer[1] = "r" buffer[2] = "r" buffer[3] = "." buffer[4] = 13 buffer[5] = 10 buffer[6] = 0 ENDIF outloop: USBService ' Must service USB regularly USBOut 3, buffer, 7, outloop Goto idleloop ' Wait for next buffer
When using Darrel's includes do not add any USBInit.Code:LOW REDLED LOW BLUELED LOW GREENLED Pause 10 USBInit * *' Get USB going
Dave
Always wear safety glasses while programming.
I use I2CRead/Write and LCDout with a USB connection at the same time with no problems. However, I haven't tried using Shiftin/Shiftout and USB at the same time.
I got the LCDout command working together with the USB connection thanks to the great help from DT. You can see the details in the next link
http://www.picbasic.co.uk/forum/show...4&daysprune=-1
Robert
"No one is completely worthless. They can always serve as a bad example."
Anonymous
Hi mackrackit and thanks for your attention,
"When using Darrel's includes do not add any USBInit"
Yes I know that, however if I comment USBInit and USBService it kill the program. It still run but it is not seen by the computer anymore. The include seems to be effective as I can use the PLUGGED, RX_READY and TX_READY variables inside my program without declaring them. They all read 0 whatever is happening though...
Was it tested on a 13/14K50 before? With CDC profile? or am I doing something wrong? The usage seems pretty straightforward though...
rsocor01, it is nice to know that all these can be used. Darrel's code for handling the USB is a nice time saver over handling USBService manually. It's just a nightmare when the program gets complicated.
Thanks to both of you,
Antoine.
Last edited by aberco; - 25th August 2010 at 02:47.
Ok, let's just go back to the original demo without any alteration:
... does not work.Code:' USB sample program for PIC18F4550 CDC serial port emulation ' Requires PBP 2.60 or later ' Compilation of this program requires that specific support files be ' available in the source directory. For detailed information, see ' the file PBP\USB18\USB.TXT. ASM CONFIG CPUDIV=NOCLKDIV ; CPU runing at full speed CONFIG USBDIV=OFF ; Low speed USB clock diviser disabled, not used here CONFIG FOSC=HS ; Use of High Speed crystal oscillator CONFIG PLLEN=ON ; Enable PLL multiplier, 12Mhz oscilator x 4 CONFIG PCLKEN=ON ; Primary clock source is enabled CONFIG FCMEN=OFF ; Failsafe clock off CONFIG IESO=OFF ; Oscillator switchover mode disabled CONFIG WDTEN=ON ; Watchdog timer on CONFIG WDTPS=512 ; Watchdog divider is 512 CONFIG MCLRE=OFF ; Disable MCLR pin, enable RC3 CONFIG STVREN=ON ; Stack full/underflow will cause reset CONFIG LVP=OFF ; Low voltage programming disabled CONFIG BBSIZ=OFF ; 512kW block boot size CONFIG XINST=OFF ; Extended instruction mode disabled ENDASM Include "cdc_desc.bas" ' Include the CDC descriptors INCLUDE "USB_ASM_Service.pbp" ' USB Init and Service interrupt routines 'Define pin function TRISA = %00000000 'PortA all digital output TRISB = %00000000 'PortB all digital output TRISC = %00000000 'PortC all digital output ANSEL = %00000000 'Disable analog input on other pins ANSELH = %00000000 'Disable analog input on other pins 'Define weak pullups WPUA = %00000000 'No weak pullup on portA WPUB = %00000000 'No weak pullup on portB Define OSC 48 buffer Var Byte[16] cnt Var Byte 'Pin function declaration Pause 10 ' USBInit ' Get USB going ' Wait for USB input idleloop: ' USBService ' Must service USB regularly cnt = 16 ' Specify input buffer size USBIn 3, buffer, cnt, idleloop ' Message received buffer[0] = "H" buffer[1] = "e" buffer[2] = "l" buffer[3] = "l" buffer[4] = "o" buffer[5] = " " buffer[6] = "W" buffer[7] = "o" buffer[8] = "r" buffer[9] = "l" buffer[10] = "d" buffer[11] = 13 buffer[12] = 10 buffer[13] = 0 outloop: ' USBService ' Must service USB regularly USBOut 3, buffer, 14, outloop Goto idleloop ' Wait for next buffer
I must say that after 2 days of digging the forum and the internet I am starting to get clueless about what to do to solve it. Is there a timer or an interrupt register to set up manually in order to run it properly? I could try to run it on a 18F4550 board I have but that won't solve the problem for my 13K50 project.
Also, I found out that USB_ASM_Service.pbp does not work in conjunction with INDT_INTS-18.bas and SPWM_INT.bas from Darell. I will need at least the latter, so maybe I should find another solution than actually trying to use USB_ASM_Service.pbp.
Any idea for troubleshooting this? or pointing to an interrupt solution that I could use? I'm starting to get clueless. Any help greatly appreciated!
BTW, I'm running PBP 2.60 in MCS 4.0.0.0, in conjunction with MPLAB 8.53.
Bookmarks