collapse

* Links de Robótica

* Posts Recentes

Palavras Cruzadas por Hugu
[Hoje às 02:48]


Editor online de imagens p/ distorcer imagens trapezoidais p/ rectangulo? por Hugu
[Hoje às 01:26]


[Projecto] Bomba Airsoft por SrMorte
[Ontem às 23:51]


Apresentação por SrMorte
[Ontem às 22:32]


Medir Agua que está no Poço por filjoa
[21 de Setembro de 2017, 20:58]


URGENTE - display de 7 segmentos com backpack por helderjsd
[20 de Setembro de 2017, 12:30]


Preços e fabricantes de pcb por Sérgio_Sena
[19 de Setembro de 2017, 10:20]


Isaac Asimov - I, Robot por senso
[18 de Setembro de 2017, 03:41]


ic SL440 da Plessey? por senso
[16 de Setembro de 2017, 13:11]


Compra Colectiva RS-Amidata por brunus
[15 de Setembro de 2017, 22:31]

Autor Tópico: bootloader TinyBLD  (Lida 2092 vezes)

0 Membros e 1 Visitante estão a ver este tópico.

Offline tretas

  • Mini Robot
  • *
  • Mensagens: 8
bootloader TinyBLD
« em: 16 de Janeiro de 2010, 19:04 »
Boas pessoal

Alguem pode me controlar aqui a _config deste bootloader

o meu quartz é de 4 mhz


Código: [Seleccione]
radix DEC
LIST      P=18F2685 ; change also: Configure->SelectDevice from Mplab
xtal EQU 4000000 ; you may want to change: _XT_OSC_1H  _HS_OSC_1H  _HSPLL_OSC_1H
baud EQU 19200 ; standard TinyBld baud rates: 115200 or 19200
; The above 3 lines can be changed and buid a bootloader for the desired frequency (and PIC type)

;********************************************************************
; Tiny Bootloader 18F series Size=100words
; claudiu.chiculita@ugal.ro
; http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm
;********************************************************************
;thanks to Inácio

#include "icdpictypes.inc" ;takes care of: #include "p18fxxx.inc",  max_flash, IdTypePIC
#include "spbrgselect.inc" ; RoundResult and baud_rate

#define first_address max_flash-200 ;100 words

   
__CONFIG  _CONFIG1H , _OSC_XT_1H
       
__CONFIG  _CONFIG2L , _BOREN_BOHW_2L & _BORV_3_2L & _PWRT_ON_2L
          ; _BORV_0_2L , _BORV_1_2L , _BORV_2_2L , _BORV_3_2L
__CONFIG  _CONFIG2H , _WDT_OFF_2H & _WDTPS_128_2H
__CONFIG  _CONFIG4L , _XINST_OFF_4L & _BBSIZ_1024_4L & _STVREN_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L ; _STVREN_ON_4L  --Stack ligado

__CONFIG  _CONFIG5L, 0xFF       ;No code protection.
__CONFIG  _CONFIG5H, 0xFF       ;
__CONFIG  _CONFIG6L, 0xFF       ;
__CONFIG  _CONFIG6H, 0XFF       ;
__CONFIG  _CONFIG7L, 0xFF       ;
__CONFIG  _CONFIG7H, 0xFF       ;
;----------------------------- PROGRAM ---------------------------------
cblock 0
crc
i
cnt1
cnt2
cnt3
counter_hi
counter_lo
flag
endc
cblock 10
buffer:64
dummy4crc
endc

SendL macro car
movlw car
movwf TXREG
endm

;0000000000000000000000000 RESET 00000000000000000000000000

ORG     0x0000
GOTO    IntrareBootloader

;view with TabSize=4
;&&&&&&&&&&&&&&&&&&&&&&&   START     &&&&&&&&&&&&&&&&&&&&&&
;----------------------  Bootloader  ----------------------
;PC_flash: C1h U H L x  ...  <64 bytes>   ...  crc
;PC_eeprom: C1h     40h   EEADR   EEDATA 0 crc
;PC_cfg C1h U OR 80h H L 1 byte crc
;PIC_response:    type `K`

ORG first_address ;space to deposit first 4 instr. of user prog.
nop
nop
nop
nop
org first_address+8
IntrareBootloader
;init serial port
movlw b'00100100'
movwf TXSTA
movlw spbrg_value
movwf SPBRG
movlw b'10010000'
movwf RCSTA
;wait for computer
rcall Receive
sublw 0xC1 ;Expect C1h
bnz way_to_exit
SendL IdTypePIC ;send PIC type
MainLoop
SendL 'K' ; "-Everything OK, ready and waiting."
mainl
clrf crc
rcall Receive ;Upper
movwf TBLPTRU
movwf flag ;(for EEPROM and CFG cases)
rcall Receive ;Hi
movwf TBLPTRH
movwf EEADR ;(for EEPROM case)
rcall Receive ;Lo
movwf TBLPTRL
movwf EEDATA ;(for EEPROM case)

rcall Receive ;count
movwf i
incf i
lfsr FSR0, (buffer-1)
rcvoct ;read 64+1 bytes
movwf TABLAT ;prepare for cfg; => store byte before crc
rcall Receive
movwf PREINC0
decfsz i
bra rcvoct

tstfsz crc ;check crc
bra ziieroare
btfss flag,6 ;is EEPROM data?
bra noeeprom
movlw b'00000100' ;Setup eeprom
rcall Write
bra waitwre
noeeprom
btfss flag,7 ;is CFG data?
bra noconfig
tblwt* ;write TABLAT(byte before crc) to TBLPTR***
movlw b'11000100' ;Setup cfg
rcall Write
bra waitwre
noconfig
;write
eraseloop
movlw b'10010100' ; Setup erase
rcall Write
TBLRD*- ; point to adr-1

writebigloop
movlw 8 ; 8groups
movwf counter_hi
lfsr FSR0,buffer
writesloop
movlw 8 ; 8bytes = 4instr
movwf counter_lo
writebyte
movf POSTINC0,w ; put 1 byte
movwf TABLAT
tblwt+*
decfsz counter_lo
bra writebyte

movlw b'10000100' ; Setup writes
rcall Write
decfsz counter_hi
bra writesloop
waitwre
;btfsc EECON1,WR ;for eeprom writes (wait to finish write)
;bra waitwre ;no need: round trip time with PC bigger than 4ms

bcf EECON1,WREN ;disable writes
bra MainLoop

ziieroare ;CRC failed
SendL 'N'
bra mainl
 
;******** procedures ******************

Write
movwf EECON1
movlw 0x55
movwf EECON2
movlw 0xAA
movwf EECON2
bsf EECON1,WR ;WRITE
nop
;nop
return


Receive
movlw xtal/2000000+1 ; for 20MHz => 11 => 1second delay
movwf cnt1
rpt2
clrf cnt2
rpt3
clrf cnt3
rptc
btfss PIR1,RCIF ;test RX
bra notrcv
    movf RCREG,w ;return read data in W
    addwf crc,f ;compute crc
return
notrcv
decfsz cnt3
bra rptc
decfsz cnt2
bra rpt3
decfsz cnt1
bra rpt2
;timeout:
way_to_exit
bcf RCSTA, SPEN ; deactivate UART
bra first_address
;*************************************************************
; After reset
; Do not expect the memory to be zero,
; Do not expect registers to be initialised like in catalog.

            END


Cumprimentos

Zé Tretas

Offline tretas

  • Mini Robot
  • *
  • Mensagens: 8
Re: bootloader TinyBLD
« Responder #1 em: 16 de Janeiro de 2010, 19:40 »
Boas

No post de cima esqueci-me de meter os warning que dava quando compilo

Citar
Warning[230] C:\USERS\DESKTOP\TINYBLD198\18F2685\TINYBLD18F2685_4MHZ_19200.ASM 20 : __CONFIG has been deprecated for PIC18 devices.  Use directive CONFIG.
Warning[230] C:\USERS\DESKTOP\TINYBLD198\18F2685\TINYBLD18F2685_4MHZ_19200.ASM 22 : __CONFIG has been deprecated for PIC18 devices.  Use directive CONFIG.
Warning[230] C:\USERS\DESKTOP\TINYBLD198\18F2685\TINYBLD18F2685_4MHZ_19200.ASM 24 : __CONFIG has been deprecated for PIC18 devices.  Use directive CONFIG.
Warning[230] C:\USERS\DESKTOP\TINYBLD198\18F2685\TINYBLD18F2685_4MHZ_19200.ASM 25 : __CONFIG has been deprecated for PIC18 devices.  Use directive CONFIG.
Warning[230] C:\USERS\DESKTOP\TINYBLD198\18F2685\TINYBLD18F2685_4MHZ_19200.ASM 27 : __CONFIG has been deprecated for PIC18 devices.  Use directive CONFIG.
Warning[230] C:\USERS\DESKTOP\TINYBLD198\18F2685\TINYBLD18F2685_4MHZ_19200.ASM 28 : __CONFIG has been deprecated for PIC18 devices.  Use directive CONFIG.
Warning[230] C:\USERS\DESKTOP\TINYBLD198\18F2685\TINYBLD18F2685_4MHZ_19200.ASM 29 : __CONFIG has been deprecated for PIC18 devices.  Use directive CONFIG.
Warning[230] C:\USERS\DESKTOP\TINYBLD198\18F2685\TINYBLD18F2685_4MHZ_19200.ASM 30 : __CONFIG has been deprecated for PIC18 devices.  Use directive CONFIG.
Warning[230] C:\USERS\DESKTOP\TINYBLD198\18F2685\TINYBLD18F2685_4MHZ_19200.ASM 31 : __CONFIG has been deprecated for PIC18 devices.  Use directive CONFIG.
Warning[230] C:\USERS\DESKTOP\TINYBLD198\18F2685\TINYBLD18F2685_4MHZ_19200.ASM 32 : __CONFIG has been deprecated for PIC18 devices.  Use directive CONFIG.

BUILD SUCCEEDED
« Última modificação: 16 de Janeiro de 2010, 19:45 por tretas »

Offline Tyran

  • Mini Robot
  • *
  • Mensagens: 293
Re: bootloader TinyBLD
« Responder #2 em: 16 de Janeiro de 2010, 20:43 »
Experimenta trocar __CONFIG por CONFIG

Offline maurosmartins

  • Mini Robot
  • *
  • Mensagens: 483
    • msm
Re: bootloader TinyBLD
« Responder #3 em: 16 de Janeiro de 2010, 21:49 »
Olá tretas, estar a explicar não é fácil, mas se me disseres qual o PIC o cristal e o baudrate, eu tento compilar-te o bootloader...

Cumprimentos, Mauro.

Offline tretas

  • Mini Robot
  • *
  • Mensagens: 8
Re: bootloader TinyBLD
« Responder #4 em: 16 de Janeiro de 2010, 22:01 »
Boas

Citar
Olá tretas, estar a explicar não é fácil, mas se me disseres qual o PIC o cristal e o baudrate, eu tento compilar-te o bootloader...

PIC :       18F2685
Quartz :  4MHz

E o baudrate ... quanto mais rapido melhor, mas penso que com um quartz de 4 MHz não deve dar
mais e 19200 ... se não o ideal seria 57600 pois com 115200 bps penso que deve dar muitos erros

Cumprimentos

Offline tretas

  • Mini Robot
  • *
  • Mensagens: 8
Re: bootloader TinyBLD
« Responder #5 em: 20 de Junho de 2010, 19:37 »
Boas

venho dai aqui um "up"

e aproveitar e alterar o quartz para 20MHz

Cumprimentos

Zé Tretas