Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
USE_TXENABLE 16F1783 timeout
#1
Hey!

Thank you for the great software.
It works great:

Initiating write...
Searching for bl . . . . . . .
Found PIC16F1783 fw ver. 1.0.2
Waiting for the boot loader to be ready...ok
Hex file successfully parsed
Writing flash....ok
Tx 387 bytes / Rx 14 bytes / 4,4s
Write successfully completed

However when i enable USE_TXENABLE it will just time out:

Initiating write...
Searching for bl . .
Found PIC16F1783 fw ver. 1.0.2
Waiting for the boot loader to be ready...ok
Hex file successfully parsed
Writing flash....response timed out
Write flash failed
Tx 8 bytes / Rx 4 bytes / 30,9s
Write failed

So how could i fix this?

Hoping for help.
Peeter
Reply
#2
Hi Peter,
Why do you want to use a tx enable pin if it works without?
Reply
#3
Hey Mikael!

I want to implement it for RS485. That is the reason.

Thank you for fast answer!
Reply
#4
Hey again.

I think i was misleading abit.
I am using bootloader over UART to USB and it is working. Now since i plan to use it with UART to RS485 to USB i was testing out this tx enable pin. I am stil using UART to USB and i am just hoping to watch the tx enable pin on oscilloscope. But as you can see if i enable this option it will not get contact anymore.

I hope it is clearer now Smile

Thanks!
Peeter
Reply
#5
PHP Code:
;------------------------------------------------------------------------------
Send()
;------------------------------------------------------------------------------        
Send    Enable tx
        ifdef USE_TXENABLE
            
;bcf        RCSTA_CREN            ;disable serial receiver COMMENTED OUT
            movwf    TEMP
            banksel    PORTR_TXE            
            bsf        PORTR_TXE
PORTB_TXE;bank ?
            
movlw    TXE_DELAY_CNT
            movwf    cnt1
txe_del_lo    decfsz    cnt1
            
goto    txe_del_lo
            movfw    TEMP
        
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
            banksel    PORTR_TXE
            bcf        PORTR_TXE
PORTB_TXE;bank ?            
            ;
bsf        RCSTA_CREN            ;enable serial receiver COMMENTED OUT
        
endif
        ; 
Send complete
        
return 

Hey!
I got it working by commenting out enable/disable serial receiver lines.
Why was it needed to enable/disable receiver?
Reply
#6
Hello!

I have a same problem with PIC18F26K22.
I use RS485 line, and I can not write flash.
Error is:
Initiating write...
     Searching for bl . . . . . .
     Found PIC18F26K22 fw ver. 3.0.2
     Waiting for the boot loader to be ready...ok
     Hex file successfully parsed
     Writing flash.... response timeout
     Writing flash...
     Write flash failed
     Tx 164 bytes / Rx 9 bytes / 3s
     Write failed
Or:
Initiating write...
     Searching for bl .
     Found PIC18F26K22 fw ver. 3.0.2
     Waiting for the boot loader to be ready...ok
     Hex file successfully parsed
     Writing flash....unknown response 0xFF
     Writing flash...
     Write flash failed
     Tx 159 bytes / Rx 9 bytes / 0,5s
     Write failed

But I can write the eeprom with same config:
Initiating write...
     Searching for bl . . . . . .
     Found PIC18F26K22 fw ver. 3.0.2
     Waiting for the boot loader to be ready...ok
     Hex file successfully parsed
     Writing eeprom...ok
     Tx 454 bytes / Rx 68 bytes / 3,8s
     Write successfully completed

It work without RS485 perfectly:
Initiating write...
     Searching for bl .
     Found PIC18F26K22 fw ver. 3.0.2
     Waiting for the boot loader to be ready...ok
     Hex file successfully parsed
     Writing flash....ok
     Writing eeprom...ok
     Tx 3,9kB / Rx 160 bytes / 5,6s
     Write successfully completed
Reply
#7
Hey!
Status update:
I got it working with RS485.

I belive the root problem is at uart.inc at function Send().
The last few statements are:
; Disable tx
PHP Code:
ifdef USE_TXENABLE
   banksel PORTR_TXE
   bcf PORTR_TXE
PORTB_TXE;bank 
   bsf RCSTA_CREN ;enable serial receiver
endif 

Now with this I cannot write flash memory.
I changed this to enable receiver as first instruction after send and now it is working:
PHP Code:
ifdef USE_TXENABLE
   bsf RCSTA_
CREN ;enable serial receiver
   banksel PORTR_TXE
   bcf PORTR_TXE
PORTB_TXE;bank 
endif 
Another way to get this working is to just comment out disable/enable RX.
Maybe there is problem, where PC program is answering too fast and RX is still disabled at that moment?
Reply
#8
I measured the communication with scop. I attached the pictures. Red is a TX line, and yellow is an RX line from PC.
EEPROM write working fine in both communication (RS232, RS485). FLASH writhe working only with RS232.
I think, in flash write mode answare the PIC too fast. TXE_DELAY number has no effect.
Attachment:
1: RS485 flash write
2: RS485 flash write enlarged
3: RS232 flash write
4: RS485 eeprom write
5: RS485 eeprom write enlarged


Attached Files Thumbnail(s)
                   
Reply
#9
Hi,
Thank you petspats for the report. I was able to reproduce the problem and fix it with your path. The problem is that the RCSTA register may be located in a different memory bank than the tx enable pin port register. I will publish a new version of the ds30 Loader free edition package when I get time.

miklosch: please start a separate thread.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)