Does someone have example for this PIC?
I can't get it to work...
Printable View
Does someone have example for this PIC?
I can't get it to work...
I searched the whole forum and I only found examples for the PIC18f2550 and 4550.
Does PBP2.60 support USB on 18F87J50?
For the second day of trying all possible examples and with all possible fuse configuration but nothing show in device menager, not even device not recognised...
I bought this development system from mikroe, thinking that the is a hardware problem, but still nothing...
What are my other options:confused:
Should work. I had the 18F67J50 (same family) running CDC. I can try to get an example for it going for HID. By the way, are you using DT_HID260 ? Will try to get something up tonight, or tomorrow morning.
Yes, I tried that and DT_HID. But nothing happen if cable is plugged or unplugged.
For now, CDC will be good starting point.
I would be very grateful if you could send me CDC example with fuse configuration.
Thank you very much.
Well, now I am starting to wonder if I ever had it working on CDC.:( I had a cdc labeled program for it, but what I had does not work. I had a fairly quick time with the 47J53 in CDC as well as HID, but for the 67J50, I can't seem to get either to work, and I have spent a fair amount of time at it.
These were the configs I used for other programs for the 67J50, which pretty much matches Microchip's HID bootloader software.
I will try a few more things, but I wanted to give you a heads up.Code:
'DEFINE LOADER_USED 1
'DEFINE RESET_ORG 1000h ' For Microchip USB Bootloader
#config
CONFIG PLLDIV = 5 ;for 20 mhz chip
CONFIG XINST = OFF
CONFIG STVREN = ON ;stack overflow reset
CONFIG WDTEN = OFF
CONFIG CP0 = OFF
CONFIG IESO = OFF
CONFIG FCMEN = OFF
CONFIG CCP2MX = DEFAULT
CONFIG WDTPS = 32768
CONFIG CPUDIV = OSC1 ;DIVIDE BY 1 MODE
CONFIG FOSC = HSPLL
CONFIG MSSPMSK = MSK5
#endconfig
DEFINE OSC 48
clear
OSCTUNE.6 = 1 ' Enable PLL for 18F87J50 family
I try cdc from pbp/usb18 and add config, but still nothing...
I use 8MHz crystal, so PPLDIV is 2 is that correct?
What are the chances that the USB module on 3 PIC are broken?
Not very high. But (speaking for myself), the chances of the problem being behind the keyboard is pretty high! Just not sure what I could be missing here, doing it two different ways hid, and cdc, and with a USB bootloader, and without. So I am running out of things I can think of to try....
Yes, divide by two would be correct for a 8 mhz.
I check hardware and recheck, and everything seems ok.
Here is code for cdc from pbp/usb18:
I spend another day on it, and nothig, rely, nothin on usb...Code:asm
CONFIG PLLDIV = 2 ;for 8 mhz chip
CONFIG XINST = OFF
CONFIG STVREN = ON ;stack overflow reset
CONFIG WDTEN = OFF
CONFIG CP0 = OFF
CONFIG IESO = OFF
CONFIG FCMEN = OFF
CONFIG CCP2MX = DEFAULT
CONFIG WDTPS = 32768
CONFIG CPUDIV = OSC1 ;DIVIDE BY 1 MODE
CONFIG FOSC = HSPLL
CONFIG MSSPMSK = MSK5
endasm
Include "cdc_desc.bas" ' Include the HID descriptors
Define OSC 48
buffer Var Byte[16]
cnt Var Byte
OSCTUNE.6 = 1 ' Enable PLL for 18F87J50 family
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 really don't know what to do.
Well, I am not having any luck over here either. Here is my try at using DT_HID260. I have been successful in getting it running on another J chip, the PIC18F47J53, and looking at the two data sheets, the USB doesnt seem to differ much between these two chips. Except on one the USB data memory is below the buffer descriptors, and the other the USB data memory is above the buffer descriptors. The DEV files seem to point to the USB buffer descriptors (67J50 here): USBMEMORYADDRESS Con $400 ' USB RAM starts here
Here is my code (that does not work)
Code:'***************************************************************************
'* Name : BasicUSB.pbp *
'* Author : Darrel Taylor *
'* Notice : Copyright (c) 2009 *
'* Date : 7/23/2009 *
'* Version : 1.x ' Modified by scalerobotics *
'* Notes : I tried to edit it to work on a PIC18F67J50 and I failed *
'* : Worked great on other chips, but I can't seem to figure out *
'* : the problem for PIC18F67J50. Board is PIC_LCD3310, which does*
'* : work with the USB bootloader,so probably not a hardware issue*
'***************************************************************************
'DEFINE LOADER_USED 1
'DEFINE RESET_ORG 1000h ' For Microchip USB Bootloader
;--- if you un-comment these, you must comment the ones in the .inc file ---
ASM ; 18F2550/4550, 20mhz crystal
; __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
; __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
; __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
; __CONFIG _CONFIG3H, _PBADEN_OFF_3H
; __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
ENDASM
;ASM ; 18F13K50/14K50 Only 12mhz crystal can be used for USB
; 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
#config ;pic18F67J50 on Olimex PIC_LCD3310 usb board
CONFIG PLLDIV = 5 ;for 20 mhz crystal
CONFIG XINST = OFF
CONFIG STVREN = off ;stack overflow reset
CONFIG WDTEN = OFF ;added
CONFIG CP0 = OFF ;added
CONFIG IESO = OFF ;added
CONFIG FCMEN = OFF ;added
CONFIG CCP2MX = DEFAULT ;added
CONFIG WDTPS = 32768
CONFIG CPUDIV = OSC1 ;DIVIDE BY 1 MODE
CONFIG FOSC = HSPLL
CONFIG MSSPMSK = MSK5 ;add
#endconfig
DEFINE OSC 48
clear
OSCTUNE.6 = 1 ' Enable PLL for 18F87J50 family
;--- Setup Interrupts ------------------------------------------------------
INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler USB_Handler
endm
INT_CREATE ; Creates the interrupt processor
endasm
;--- Setup USB -------------------------------------------------------------
INCLUDE "DT_HID260.pbp"
DEFINE USB_VENDORID 6017
DEFINE USB_PRODUCTID 2000
DEFINE USB_VERSION 1
DEFINE USB_VENDORNAME "Darrel Taylor"
DEFINE USB_PRODUCTNAME "DT_HID"
DEFINE USB_SERIAL "001"
DEFINE USB_INSIZE 32 ; IN report is PIC to PC (8,16,32,64)
DEFINE USB_OUTSIZE 16 ; OUT report is PC to PIC
DEFINE USB_POLLIN 10 ; Polling times in mS, MIN=1 MAX=10
DEFINE USB_POLLOUT 10
; --- Each USB LED is optional, comment them if not used ----
;DEFINE USB_LEDPOLARITY 1 ; LED ON State [0 or 1] (default = 1)
;DEFINE USB_PLUGGEDLED PORTB,0 ; LED indicates if USB is connected
;DEFINE USB_TXLED PORTC,2 ; " " data being sent to PC
;DEFINE USB_RXLED PORTC,1 ; " " data being received from PC
OutCount VAR WORD : OutCount = 0
Value VAR WORD
X VAR WORD
;--- Setup ADC -------------------------------------------------------------
DEFINE ADC_BITS 10 ; Number of bits in ADCIN result
' Configure ADC
' =============
' See thread http://www.picbasic.co.uk/forum/showthread.php?t=11128&highlight=18f67j50
' for more information about setting analog, and the WDTCON.4 on this chip
WDTCON.4 = 1 ' Switch to Alternate SFR
ANCON0_ALT = %10011110
' -xx------ Not Implemented
' 1--1111-- AN7, & AN<4:1> = Digital
' -------0- AN0 = Analog
ANCON1_ALT = %11111111
' 11111111- AN<15:10> = Digital
WDTCON.4 = 0 ' Back to Default SFR
ADCON0 = %00000001
' 0-------- VCFG1, Vref- 0 = AVss (1=AN2)
' -0------- VCFG2, Vref+ 0 = AVdd (1=AN3)
' --0000--- CHS<3:0>, Channel select -- 0
' ------0-- Go/Done, don't care for now
' -------1- ADON, Enable ADC
ADCON1 = %10000111
' 1-------- ADFM, Right justified result
' -0------- ADCAL, Normal A/D converter operation
' --000---- ACQT<2:0>, A/D Aquisition time = 0 Tad
' -----111- ADCS<2:0>, A/D conversion clock = FRC
;--- The Main Loop ---------------------------------------------------------
TRISD = 0
PORTD.0 = 1 'turn on g sensor
PORTD.1 = 0 'select scale for g sensor
PORTD.2 = 0 'select scale for g sensor
TRISA = %00000111 'set porta.0, 1, and 2 as inputs
TRISB = 0
CM1CON1 = 7 'CM1CON in PBP3 as CM1CON1
CM2CON1 = 7 'CM2CON in PBP3 as CM2CON1
TRISC = 0
TRISE = 0
pause 100
;--- The Main Loop ---------------------------------------------------------
Main:
FOR X = 0 to 1000 ; Check for incomming USB data while pausing
@ ON_USBRX_GOSUB _HandleRX
PAUSE 1
NEXT X
ADCIN 10, Value
OutCount = OutCount + 1
ARRAYWRITE USBTXBuffer,["AN0=",DEC Value," -",DEC OutCount," "]
IF Plugged THEN GOSUB DoUSBOut ; only send when USB is connected
GOTO Main
;---- This just sends the received packet back to the PC -------------------
HandleRX:
ARRAYWRITE USBTXBuffer,[STR USBRXBuffer\USBBufferSizeRX]
return
I try similar thing, but same result.
So is it possible there are some bug in PBP for this PIC family?
I'm looking into it too.
Trying to build a board.
But first I have to ask ...
Do you have VDD (3.3V) tied to VUSB?
There's no internal regulator on those chips.
I can't speak for Pedja's board, But I am pretty sure Walter is using the PIC_LCD3310. If so that DOES show Vusb tied to 3.3V on the schamatic.
Thanks!
Yes, I am using Olimex's PIC_LCD3310. Making a board for this family is a little bit of a pain. Darrel, do you want me to send you the Olimex board? I can ship it out tomorrow.
Walter
Thanks Walter, that's a nice offer.
But I ordered one from sparkfun. They're only 50 miles away so I should have it by friday, shipped ground.
That's sure easier than building one.
I'm going to try a 26J50 too.
The 87J50 may still be a question mark.
Now that's what I call support! Thanks Darrel.
I can vouch for the PIC18F46J50 working with DT_HID260 and PBP3. I have Micochip's mini demo board http://www.microchip.com/stellent/id...cName=en540669 going. But the 67J50 is elusive for me. Not ruling out my own operator error here, but this operator is running out of ideas ..
Darrel, thank for support.
I have 3.3V om Vusb... That was first thing to check...
I can send you PIC. Just give me adress.
Thanks Pedja,
We have some of those chips, but no boards to put it on.
At least none that would be easy to use.
I think the 67J50 should be good enough since it's in the same family as the 87J50.
We shall see this weekend.
Dear sir,
Thank you for support.
There is something seriously messed up with these chips. And it's all Microchip.
The SFR's from address F40h to F5Fh cannot be accessed with either the MOVFF opcode or indirectly through the FSR's.
They can only be accessed by setting BSR to bank15 and using "banked" opcodes like movf, movwf, bcf etc.
I realize that those SFR's are outside of the ACCESS bank, but that should not affect MOVFF or indirect addressing thru FSR's.
That range of SFR's contains many of the USB modules registers.
Other USB module registers such as UCON USTAT etc that reside in the access bank can be written/read with all 3 methods FSR, MOVFF and banked. So it's not related to the USB module itself.
The USB libraries rely heavily on MOVFF and FSR's.
I have found nothing in the errata or datasheet that mentions this behavior.
To illustrate the issue, here is a program for the Olimex PIC_LCD3310.
It attempts to read several SFR's using all 3 methods and displays the result on the GLCD. With anything in the affected range, only the banked method (GetR on the display) returns a value. Any other SFR's work fine.
Use Up and Down on the joystick to scroll thru the SFR's.
Walter,Code:'***************************************************************************
'* Name : 18F67J50USB.pbp *
'* Author : Darrel Taylor *
'* Notice : Copyright (c) 2009 *
'* Date : 8/21/2011 *
'* Notes : The FSR's from F40 to F5F are not accessable using either *
'* : MOVFF or indirectly with FSR's. *
'***************************************************************************
#config ;pic18F67J50 on Olimex PIC_LCD3310 usb board
CONFIG PLLDIV = 5 ;for 20 mhz crystal
CONFIG XINST = OFF
CONFIG STVREN = off ;stack overflow reset
CONFIG WDTEN = OFF ;added
CONFIG CP0 = OFF ;added
CONFIG IESO = OFF ;added
CONFIG FCMEN = OFF ;added
CONFIG CCP2MX = DEFAULT ;added
CONFIG WDTPS = 32768
CONFIG CPUDIV = OSC1 ;DIVIDE BY 1 MODE
CONFIG FOSC = HSPLL
CONFIG MSSPMSK = MSK5 ;add
#endconfig
DEFINE OSC 48
clear
OSCTUNE.6 = 1 ' Enable PLL for 18F87J50 family
PAUSE 200
;--- For the 3310 display---------------------------------------------------
include "AllDigital.pbp"
;DEFINE SHOWDIGITAL 1
include "modedefs.bas"
include "LCD_3310v32.inc"
GOSUB Lcd_Clear
;--- Setup Interrupts ------------------------------------------------------
INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" ; Allows re-entry to PBP from ASM interrupts
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler USB_Handler
INT_Handler TMR1_INT, _TMR1_ISR, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts
endasm
;--- Setup USB -------------------------------------------------------------
INCLUDE "DT_HID260.pbp"
DEFINE USB_VENDORID 6017
DEFINE USB_PRODUCTID 2000
DEFINE USB_VERSION 1
DEFINE USB_VENDORNAME "Darrel Taylor"
DEFINE USB_PRODUCTNAME "DT_HID"
DEFINE USB_SERIAL "001"
DEFINE USB_INSIZE 32 ; IN report is PIC to PC (8,16,32,64)
DEFINE USB_OUTSIZE 16 ; OUT report is PC to PIC
DEFINE USB_POLLIN 10 ; Polling times in mS, MIN=1 MAX=10
DEFINE USB_POLLOUT 10
; --- Each USB LED is optional, comment them if not used ----
;DEFINE USB_LEDPOLARITY 1 ; LED ON State [0 or 1] (default = 1)
DEFINE USB_PLUGGEDLED PORTE,3 ; LED indicates if USB is connected
;DEFINE USB_TXLED PORTC,2 ; " " data being sent to PC
;DEFINE USB_RXLED PORTC,1 ; " " data being received from PC
OutCount VAR WORD : OutCount = 0
Value VAR WORD
X VAR WORD
;--- The Main Loop ---------------------------------------------------------
TRISD = 0
PORTD.0 = 1 'turn on g sensor
PORTD.1 = 0 'select scale for g sensor
PORTD.2 = 0 'select scale for g sensor
pause 100
T1CON = $31 ; Prescaler = 8, TMR1ON
LCD_Value VAR BYTE
UCFG_VAL CON EXT
B0 VAR BYTE ; Button Var
B1 VAR BYTE ; Button Var
;------------------------------------------------------------------------------
ASM
GetReg macro Regin, VarOut
banksel Regin
movf Regin, W
banksel VarOut
movwf VarOut
banksel 0
endm
ENDASM
PAUSE 100
Left VAR PORTB.1
Right VAR PORTA.4
Up VAR PORTB.4
Down VAR PORTB.5
Center VAR PORTB.0
;------------------------------------------------------------------------------
ShowUCON:
GOSUB Lcd_Clear
@ PrintStr 0,0, " UCON - F65h"
@ PrintStr 0,2, "FF = "
LCD_Value = UCON
GOSUB LCD_BIN8
@ PrintStr 0,3, "GetR= "
@ GetReg UCON, _LCD_Value
GOSUB LCD_BIN8
@ LFSR 0, UCON
@ movff INDF0, _LCD_Value
@ PrintStr 0,4, "FSR = "
GOSUB LCD_BIN8
UCON_Wait:
PAUSE 10
BUTTON Down,0,255,255,B0,0,UCON_Wait
;------------------------------------------------------------------------------
ShowUSTAT:
GOSUB Lcd_Clear
@ PrintStr 0,0, " USTAT - F64h"
@ PrintStr 0,2, "FF = "
LCD_Value = USTAT
GOSUB LCD_BIN8
@ PrintStr 0,3, "GetR= "
@ GetReg USTAT, _LCD_Value
GOSUB LCD_BIN8
@ LFSR 0, USTAT
@ movff INDF0, _LCD_Value
@ PrintStr 0,4, "FSR = "
GOSUB LCD_BIN8
USTAT_Wait:
PAUSE 10
BUTTON Up,0,255,255,B1,1,ShowUCON
BUTTON Down,0,255,255,B0,0,USTAT_Wait
;------------------------------------------------------------------------------
ShowUEIR:
GOSUB Lcd_Clear
@ PrintStr 0,0, " UEIR - F63h"
@ PrintStr 0,2, "FF = "
LCD_Value = UEIR
GOSUB LCD_BIN8
@ PrintStr 0,3, "GetR= "
@ GetReg UEIR, _LCD_Value
GOSUB LCD_BIN8
@ LFSR 0, UEIR
@ movff INDF0, _LCD_Value
@ PrintStr 0,4, "FSR = "
GOSUB LCD_BIN8
UEIR_Wait:
PAUSE 10
BUTTON Up,0,255,255,B1,1,ShowUSTAT
BUTTON Down,0,255,255,B0,0,UEIR_Wait
;------------------------------------------------------------------------------
ShowUIR:
GOSUB Lcd_Clear
@ PrintStr 0,0, " UIR - F62h"
@ PrintStr 0,2, "FF = "
LCD_Value = UIR
GOSUB LCD_BIN8
@ PrintStr 0,3, "GetR= "
@ GetReg UIR, _LCD_Value
GOSUB LCD_BIN8
@ LFSR 0, UIR
@ movff INDF0, _LCD_Value
@ PrintStr 0,4, "FSR = "
GOSUB LCD_BIN8
UIR_Wait:
PAUSE 10
BUTTON UP,0,255,255,B1,1,ShowUEIR
BUTTON Down,0,255,255,B0,0,UIR_Wait
;------------------------------------------------------------------------------
ShowUCFG:
GOSUB Lcd_Clear
@ PrintStr 0,0, " UCFG - F5Fh"
@ PrintStr 0,2, "FF = "
LCD_Value = UCFG
GOSUB LCD_BIN8
@ PrintStr 0,3, "GetR= "
@ GetReg UCFG, _LCD_Value
GOSUB LCD_BIN8
@ LFSR 0, UCFG
@ movff INDF0, _LCD_Value
@ PrintStr 0,4, "FSR = "
GOSUB LCD_BIN8
UCFG_Wait:
PAUSE 10
BUTTON Up,0,255,255,B1,1,ShowUIR
BUTTON Down,0,255,255,B0,0,UCFG_Wait
;------------------------------------------------------------------------------
ShowUADDR:
GOSUB Lcd_Clear
@ PrintStr 0,0, " UADDR - F5Eh"
@ PrintStr 0,2, "FF = "
LCD_Value = UADDR
GOSUB LCD_BIN8
@ PrintStr 0,3, "GetR= "
@ GetReg UADDR, _LCD_Value
GOSUB LCD_BIN8
@ LFSR 0, UADDR
@ movff INDF0, _LCD_Value
@ PrintStr 0,4, "FSR = "
GOSUB LCD_BIN8
UADDR_Wait:
PAUSE 10
BUTTON Up,0,255,255,B1,1,ShowUCFG
BUTTON Down,0,255,255,B0,0,UADDR_Wait
;------------------------------------------------------------------------------
ShowUEIE:
GOSUB Lcd_Clear
@ PrintStr 0,0, " UEIE - F5Dh"
@ PrintStr 0,2, "FF = "
LCD_Value = UEIE
GOSUB LCD_BIN8
@ PrintStr 0,3, "GetR= "
@ GetReg UEIE, _LCD_Value
GOSUB LCD_BIN8
@ LFSR 0, UEIE
@ movff INDF0, _LCD_Value
@ PrintStr 0,4, "FSR = "
GOSUB LCD_BIN8
UEIE_Wait:
PAUSE 10
BUTTON Up,0,255,255,B1,1,ShowUADDR
BUTTON Down,0,255,255,B0,0,UEIE_Wait
;------------------------------------------------------------------------------
ShowUIE:
GOSUB Lcd_Clear
@ PrintStr 0,0, " UIE - F5Ch"
@ PrintStr 0,2, "FF = "
LCD_Value = UIE
GOSUB LCD_BIN8
@ PrintStr 0,3, "GetR= "
@ GetReg UIE, _LCD_Value
GOSUB LCD_BIN8
@ LFSR 0, UIE
@ movff INDF0, _LCD_Value
@ PrintStr 0,4, "FSR = "
GOSUB LCD_BIN8
UIE_Wait:
PAUSE 10
BUTTON Up,0,255,255,B1,1,ShowUEIE
BUTTON Down,0,255,255,B0,0,UIE_Wait
;------------------------------------------------------------------------------
ShowPIE2:
GOSUB Lcd_Clear
@ PrintStr 0,0, " PIE2 - FA0h"
@ PrintStr 0,2, "FF = "
LCD_Value = PIE2
GOSUB LCD_BIN8
@ PrintStr 0,3, "GetR= "
@ GetReg PIE2, _LCD_Value
GOSUB LCD_BIN8
@ LFSR 0, PIE2
@ movff INDF0, _LCD_Value
@ PrintStr 0,4, "FSR = "
GOSUB LCD_BIN8
PIE2_Wait:
PAUSE 10
BUTTON Up,0,255,255,B1,1,ShowUIE
BUTTON Down,0,255,255,B0,0,PIE2_Wait
;------------------------------------------------------------------------------
ShowUEP0:
GOSUB Lcd_Clear
@ PrintStr 0,0, " UEP0 - F4Ch"
@ PrintStr 0,2, "FF = "
LCD_Value = UEP0
GOSUB LCD_BIN8
@ PrintStr 0,3, "GetR= "
@ GetReg UEP0, _LCD_Value
GOSUB LCD_BIN8
@ LFSR 0, UEP0
@ movff INDF0, _LCD_Value
@ PrintStr 0,4, "FSR = "
GOSUB LCD_BIN8
UEP0_Wait:
PAUSE 10
BUTTON Up,0,255,255,B1,1,ShowUIE
BUTTON Down,0,255,255,B0,0,UEP0_Wait
;--- The Main Loop ---------------------------------------------------------
Main:
FOR X = 0 to 1000 ; Check for incomming USB data while pausing
@ ON_USBRX_GOSUB _HandleRX
PAUSE 1
NEXT X
ADCIN 10, Value
OutCount = OutCount + 1
ARRAYWRITE USBTXBuffer,["AN0=",DEC Value," -",DEC OutCount," "]
IF Plugged THEN GOSUB DoUSBOut ; only send when USB is connected
GOTO Main
;---- This just sends the received packet back to the PC -------------------
HandleRX:
ARRAYWRITE USBTXBuffer,[STR USBRXBuffer\USBBufferSizeRX]
return
;----[Timer1 interrupt blinks an LED]--------------------------------------
TMR_DIV VAR BYTE
TMR1_ISR:
TMR_DIV = TMR_DIV + 1
if TMR_DIV = 12 THEN
TOGGLE PORTE.2
TMR_DIV = 0
ENDIF
@ INT_RETURN
LCD_BIN8:
Lcd_Data = LCD_Value.7 + $30
Gosub Lcd_SendChar
Lcd_Data = LCD_Value.6 + $30
Gosub Lcd_SendChar
Lcd_Data = LCD_Value.5 + $30
Gosub Lcd_SendChar
Lcd_Data = LCD_Value.4 + $30
Gosub Lcd_SendChar
Lcd_Data = LCD_Value.3 + $30
Gosub Lcd_SendChar
Lcd_Data = LCD_Value.2 + $30
Gosub Lcd_SendChar
Lcd_Data = LCD_Value.1 + $30
Gosub Lcd_SendChar
Lcd_Data = LCD_Value.0 + $30
Gosub Lcd_SendChar
RETURN
My PIC_LCD3310 arrived with a solder bridge between pins 13-14 (D+, RF5).
Sometimes those are intentional, does your have a bridge there too.
I've attached the .hex file for the above program.
Weirdness! Will have to check your program out tonight! Thanks Darrel!
No, mine do not have a solder bridge on any of the PIC pins.
Here is a USB HID bootloader, just to make sure your USB portion (still)works.
(Hold joystick in down position at power up to go to bootload mode)
Just went and looked at 1 of mine(I have 2 but must have put the other in a safe place). I see no bridges on the pins anywhere. So Darrel is it safe to assume you will create a workaround for microchips shortcoming? Haha just poking at you. Seems now that you have done the hard part and identified the issue, we need to make an asm routine to talk to those sfr's?
I found this on page 81: But I guess you found that already.
See, its a feature, not a bug!Quote:
Note: Addresses, F40h through F5Fh, are not
part of the Access Bank, therefore specifying
a BSR should be used to access these
registers.
I tried to head off that question in my earlier post.
I understand that it's outside of the access bank, but that only affects the "banked" opcodes (movf, movwf, bcf, bsf, iorwf etc). Banked opcodes are the only ones that work in that range on the 67J50.
MOVFF and indirect addressing are not affected by the BSR register.
They use the full address of the register.
From the MOVFF Instruction definition ...
Quote:
Location of source ‘fs’ can be anywhere
in the 4096-byte data space (000h to
FFFh) and location of destination ‘fd’
can also be anywhere from 000h to
FFFh.
I think it is sort of interesting that in both the PIC18F47J53, and the PIC18F46J50 (both known to work with PBP USB) it states:
However, for the PIC18F67J50, they leave the MOVFF part out of this statement. I wonder if Microchip knows its errata and just didn't add it to the errata list. Or it's just a coincidence.Quote:
Note: The SFRs located between EB0h and
F5Fh are not part of the Access Bank.
Either BANKED instructions (using BSR) or
the MOVFF instruction should be used to
access these locations. When programming
in MPLAB® C18, the compiler will
automatically use the appropriate
addressing mode.
Hmmmm, very interesting indeed.
I was out of town, now I'm reading posts, and i tested hardware with HID boot loader, and it works.
When can I expect solution?
Is this will be corrected in PBP2.60(which I currently use), or I must upgrade to PBP3?
I really appreciate your efforts.
Thanks to all;)
There's no good reason to not upgrade to PBP3... forum is free... now say to Melabs & Crownhill you appreciate the forum because it saved your butt a couple of times... get the upgrade ;)
Yes, you're right, I'll get update;)
I just saw the PBP 3 update too. Everybody - time to open your wallets. Is it really that more stable than PB2?
Good boy ;)
I have not seen a version of PBP that was not stable. So far PBP 3.0 has not given me any trouble.
UPGRADE UPGRADE UPGRADE
Maybe the faster folks upgrade the faster they will come out with more bells and whistles.
I didn't get very far on the Microchip forum. http://www.microchip.com/forums/tm.a...mpage=1#597082 They wanted me to try the simulator, and see if the simulator thought that should work or not. I couldn't get far enough in Mplab to find out. Though I am not sure how useful that would be. Does a simulator always sim what it should?
MPSIM worked with PBP 2.x, will try with PBP3. It has to.
And NO a simulator do not always give you the good results, some are worst than others. As a guideline they are usually decent tool or pure toy, not much.
What did you try in MPSIM?
I'm finding that it's reversed in MPSIM.
MOVFF and FSR's work, but banked instructions don't.
I haven't tried this specific PIC yet. I try to stay away of Sims ;)
OK, I'm getting closer.
I think I can make USB work on it.
What a screwy chip.
This is all very interesting. Care to share what you've been able to find out so far?
How is this chip different than the others?