Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Found unknown device id [solved]
#1
Hi!
Im in the process of trying out your bootloader. looks to be the most complete loader i have seen for PIC.

I have a problem:
The Gui reports "Found unknown device id " when connection to my 2-wire RS485 device. I know the HW is OK, because i have run Modbus at the same speed on it.
The device is a 12F1840 unit.
Configurations are set in code.
Through stepping i have concluded that the spbrg is calculated correctly.
Any suggestions?
This is my settings:
Code:
;------------------------------------------------------------------------------
; Device
;------------------------------------------------------------------------------
        LIST          P=12F1840


;------------------------------------------------------------------------------
; Includes
;------------------------------------------------------------------------------
        #include    "devices.inc"


;------------------------------------------------------------------------------
; User preferences
;------------------------------------------------------------------------------
        radix DEC

        #define        FOSC            1000000            ;xxx
        #define        BLTIME            5000            ;xxx time in ms before bootloader loads the user application
        #define        HELLOTRIES        2                ;xxx number of non hello characters received before branching to the user application
        

;------------------------------------------------------------------------------
; UART settings
;------------------------------------------------------------------------------
        #define        USE_UART1        1                ;xxx uncomment to use uart1
        ;#define    USE_UART2        1                ;xxx uncomment to use uart2
        #define        BAUDRATE         19200            ;xxx baudrate
        ;#define    USE_ABAUD        1                ;xxx auto baud rate detection, only available on enhanced mid-range devices(?)
        #define        USE_BRGH    1                ;xxx
        #define    USE_BRG16        1                ;xxx 16-bit brg, only available on enhanced mid-range devices(?)
        #define    USE_TXENABLE    1                ;xxx uncomment to use a tx enable pin        
        #ifdef USE_TXENABLE
            #define    TRISR_TXE        TRISA            ;xxx tris register containing tx enable
            #define    PORTR_TXE        PORTA            ;xxx port register containing tx enable
            #define    TRISB_TXE        TRISA0            ;xxx tris bit for tx enable
            #define PORTB_TXE        RA0                ;xxx port bit for tx enable
        #endif


;------------------------------------------------------------------------------
; Advanced settings
;------------------------------------------------------------------------------
        #define        BLPLW            256                ;bootloader placement, words from end, should be a multiple of 64
        
                
;------------------------------------------------------------------------------
; Configuration bits, these macros can be found at the end of the inc-files located in
; C:\Program Files\Microchip\MPASM Suite\
;
; These can also be set in MPLAB IDE instead, they are found in Configure->Configuration bits...
;------------------------------------------------------------------------------

        ; Enhanced
        __CONFIG    _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _BOREN_OFF & _IESO_OFF & _FCMEN_OFF
        __CONFIG    _CONFIG2, _PLLEN_OFF & _LVP_OFF

and my user code in the loader:

Code:
;------------------------------------------------------------------------------
; User specific entry code go here
;------------------------------------------------------------------------------    

        ; Set internal oscillator to 1MHz
        banksel    OSCCON
        bsf        OSCCON, IRCF0
        bsf        OSCCON, IRCF1
        bcf        OSCCON, IRCF2
        bsf        OSCCON, IRCF3                 
        ;IO
        banksel TRISA
        movlw B'10110'
        movwf TRISA
        ;weak pullup
        banksel WPUA
        movlw 0
        movwf WPUA
        ;assign uart to the correct pins
        banksel APFCON
        movlw B'10000100'
        movwf APFCON
Reply
#2
Hi,
Thank you posting in the forum! Your config looks good as far as I can see.
The device id constants are 495 in both firmware and GUI so there seem
to be some sort of communication/timing problem.

Please post the entire output from the GUI or a screenshot.
Which RS485 converter do you use on the PIC side?
Which rs485 chip do you use on the PIC side?
Can you post the txenable enable code from your application? Email is ok.
Reply
#3
Hi !
Thanks for your reply!
I too is of the opinion that it is some timing problem, it partly was corrected when I fixed some faulty dip-switch setting in the westermo.
I enclose the output of the GUI.
The PC side converter is a Westermo MDW-45
The PIC side converters are ISL3294 + ISL3284
Tx enable code is:
(in .h file)
Code:
#define  DEN LATA0   //Data enable

In .c file
Code:
            DEN = 1;
            //Let the DEN settle
            __delay_us(10);
            TXEN = 1;
            CPos = 0;
            while (CPos < Flen)
            {
                TXREG = ComBuf[CPos++];        //Put next char in buffer
                while (!TRMT);                //Wait for data to be shifted out
            }
            //Wait for TSR to send last bits
            while (!TXIF);

Thanks!
Jens


Attached Files Thumbnail(s)
   
Reply
#4
Thanks. In the code you have both DEN=1 and TXEN=1 what are those?

Running at 1MHz each instruction takes 4us to execute. There are three NOPs in the firmware after the tx enable pin is set high, that equals 12us which should be enough according to your code. You could however insert one or more NOPs just to rule that out.

Also insert a NOP or two after the byte has been sent. See below.

If possible, try a lower baud rate and/or higher frequency.

In ds30loader.asm
Code:
;------------------------------------------------------------------------------
; Send()
;------------------------------------------------------------------------------        
Send    ; Enable tx
        ifdef USE_TXENABLE
            banksel    PORTR_TXE
            bsf    PORTR_TXE, PORTB_TXE
            nop        ;needed?
            nop
            nop
-----------insert 1 more NOP here-------------------
        endif        
        ;Send byte
        banksel    TXREG_
        movwf     TXREG_            ;bank 0/3
        ; Wait for transmit shift register to get empty
        banksel    TXSTA_    
txwait    btfss    TXSTA_, TRMT    ;bank 1/3
        goto    txwait
        ; Disable tx
        ifdef USE_TXENABLE

-----------insert 1-3 NOPs here-------------------
            banksel    PORTR_TXE
            bcf    PORTR_TXE, PORTB_TXE    ;bank ?
        endif
        ; Send complete
        return
Reply
#5
Hi, Thanks for the answer.

The DEN is the direction control of the data. DEN = 1 is Tx and =0 is Rx(from device side)
TXEN = 1 is the internal transmitter of PIC beeing enabled.
I am nearing a working solution, I can now download hex without errors.
The key was that the bootloader has the reciver open all the time, requering the HW to turn off the Rx driver to prevent the sent data to be looped back.(not the case in my HW) I added some small code in the "Send" routine, setting CREN to 0 during transmit. Could be an improvment for future?

I still have problems, but now its the app not working correctly after beeing programmed by the bootloader.
After using the loader to program the device, neither my app or the loader runs any more.
Any suggestions?
I enlose the program memory readup after using the loader to load the hex.
Thanks, Rigor.


Attached Files
.zip   flash_after_loading.zip (Size: 28.03 KB / Downloads: 2)
Reply
#6
Great! So this is a problem for all 2-wire setups. I'd better include your fix. Thanks.

It appears you have modified the boot loader size. Did you also use the custom boot loader properties in the GUI? The PIC12/PIC16 firmware doesn't have protection so it is able to overwrite itself. I think that is what has happened.

Please attach your hex file and the entire modified boot loader firmware project.
Reply
#7
Hi, Thanks for answering.
I think it is perhaps not a problem in all 2-wire setups. Many use the same data enable wire to shut down the reciver on transmit. Then again, there it no point in keeping it open.

I include all my files below!
Thanks,
Rigor.



Attached Files
.zip   firmware PIC12F PIC16F.zip (Size: 66.76 KB / Downloads: 5)
.zip   .ds30LoaderFree.zip (Size: 1.77 KB / Downloads: 4)
.zip   tinySensor.zip (Size: 2.55 KB / Downloads: 3)
Reply
#8
Thanks. You have changed to boot loader size which in this case causes the gui to write the goto to the application in the middle of the boot loader. The next firmware version (1.0.2) will be 256 words big and GUI knows about it so you can change the firmware version in ds30loader.asm:
Code:
        #define    VERMAJ        1                                        ;firmware version major
        #define    VERMIN        0                                        ;firmware version minor
        #define    VERREV        2                                        ;firmware version revision
Reply
#9
Thanks, It works now. I had to uncheck "custom bootloader" in the GUI also.
Excellent support Mikael!
Reply
#10
Great! Thanks for the bug report.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)