usbhid and suart together

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
madru
Posts: 10
Joined: Thu Oct 22, 2009 9:07 pm

usbhid and suart together

Post by madru » Tue Nov 03, 2009 9:25 am

Hi,

is it possible to use both lib's together? - I like to see my HID debug output via RS232

Code: Select all

Device = 18F2550
Clock = 48
   
// 20Mhz crystal, 48Mhz internal (FS USB)
Config
  PLLDIV = 2,
  CPUDIV = OSC1_PLL2,
  USBDIV = 2,
  FOSC = HSPLL_HS,  //CPU=48 MHz
  PWRT   = ON,
  BOR    = OFF,
  VREGEN = ON, 		//USB Voltage Regulator Enable:
  WDT    = OFF, 	//Watchdog Timer:
  MCLRE  = OFF, 		//MCLR disabled:
  PBADEN = OFF, 	//PORTB<4:0> pins are configured as digital I/O on Reset
  LVP    = OFF 	    //Low Voltage ICSP:

Include"usbhid.bas" // <<=== as soon you include the Lib SUART is broken
Include "SUART.bas"


ReadTerminator = 13 
SetTX(PORTC.6) // whatever 
SetRX(PORTC.7) // whatever 
SetBaudrate(sbr19200)
SetMode(umTrue)
While true
   UART.Write("Test",13,10) //garbage is transmitted 



Wend

THX

M

richardb
Posts: 310
Joined: Tue Oct 03, 2006 8:54 pm

Post by richardb » Tue Nov 03, 2009 9:40 am

it's an interrupt thing. anytime the suart code is unterrupted it will bork the timing.

i do the following.

make sure your suart output is fast so the interrupt delay is minimised.

Code: Select all

Sub MyWrite(x As Byte)
        CDC.DisableISR
        UART.Write(x)
        CDC.EnableISR
End Sub
Sub debugI(y As Byte)
     MyWrite(y)
End Sub
Sub debugI(x As String)
        Dim index As Byte
        index = 0
        Repeat
            MyWrite(x(index))
            index=index+1
        Until Byte(x(index))=0
   End Sub
Public Compound Sub debug(debugI)
i havent tried with hid but i would imagine it will also work
Hmmm..

madru
Posts: 10
Joined: Thu Oct 22, 2009 9:07 pm

Post by madru » Tue Nov 03, 2009 10:10 am

BINGO

THX :P

Post Reply