Modifying source file TinyBld

Create new topics, add your comment, remark, bugs...
Post Reply
crh
Posts: 20
Joined: Wed Oct 29, 2008 11:51 am

Modifying source file TinyBld

Post by crh » Mon Jan 05, 2009 9:11 am

Hello Lubin,

Modifying source file TinyBld in relation with the masterblock.

When I try to write the hex file (a simulink model build with Matlab) with TinyBld into a dspic30f4013 I get in the GUI the error:

Connected to \\.\COM3 at 115200
Searching for PIC ...Not found,
ERROR!

I really do not know the cause of this error. Till now I suppose it is coming from a wrong way of modifying the source file from the bootloader regarding frequencies and/or baud.

I build the bootloader with the following files in MPLAB:
tinybld_ds4013.s (source: Tiny website)
p30f4013.gld (source: latest C30 full version)
p30f4013.inc (source: latest C30 full version)
Furthermore, I write the produced hex file with PicKit2 into the dspic30f4013. No problem so far. Then I try to write the hex file of the simulink model into the pic (with the max232, circuit TinyBld ) and get the error (see above).
I know, I have to modify the s file: tinybld_ds4013.s with the parameters from the masterblock. I use exact the same parameters as in your website: compile your first model.
10MHz quartz, no PLL etc.
I tried several ways but till now without any succes.
Somewhere in?

Code: Select all

;********************************************************************
;	Tiny Bootloader		dsPIC series		Size=100words
;	claudiu.chiculita@ugal.ro
;	http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm
;********************************************************************
        .equ __30F4013, 1
        .include "p30f4013.inc"
        
	;config		__FOSC, CSW_FSCM_OFF & HS;FRC & FRC_PLL4
	; fedcba9876543210
	; 11   FOS   FPR//
;	config		__FOSC, 0xC302	;HS
	;config		__FOSC, 0xC703
;	config          __FWDT, WDT_OFF
;	config          __FBORPOR, PBOR_OFF & MCLR_EN
;	config          __FGS, CODE_PROT_OFF
;check also ATIO (below)

;.equ Fcy, 5000000
;.equ baud, 19200
.equ Fcy, 7372800*4
.equ baud, 115200
.equ IdTypePIC, 0x75        ; 0x75 is also for 4011, 4012
.equ max_flash, 0x8000		;dsPIC max address
	
        .global __reset
	
	.section .nbss, "b"
buff:	.space 4
buffer:	.space 128+6
W99:	.space 2

;REGISTRY:
;W0	imediat, param nvmcon
;W1	Receive
;W2	SendL		need?
;W3	count rcv
;W4	memory buffer pointer
;W5	^
;W6	for
;W7	temp
;W8
;W9	Erase/Write Flag
;W10	delay1
;W11	delay2
;W12	EA Write 
;W13	crc
;W14	void(black hole)
;W15	stack

etc..
Regards, Casparus

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Modifying source file TinyBld

Post by LubinKerhuel » Tue Jan 06, 2009 12:34 am

Hi Casparus,

Configuration for tinybld is sometimes fastidious.
It's a long time I have not been doing it...

One good method for debugging is to make the code to send data (using the SendL macro) in an infinite loop and to check with your oscillo :
- UART Tx pin is alive!
- With an oscilloscope or HyperTerminal (windows), bit rate is Ok

As far as I remember, common problem comes from :
- DsPIC configuration (Quartz configuration: check if it is HS, XT and PLL parameters...)
- check that you use the correct dsPIC configuration set (problem with MPLAB interface...)
- Check the UART baud ( it may be better to write as a literal value the baud) :

Code: Select all

        mov     #12, W0                               ; instead of #(((Fcy/baud) / 16) - 1), W0  
        mov     w0, U1BRG                           ;to 115200 Kbaud #(((7372800/115200) / 16) - 1)
I attached the file I usually use as is : (adapt it for 4013)
tinybld_ds.s
assembly language source file for tinybld bootloader provided as is !
(5.94 KiB) Downloaded 511 times
Once configuration is done, bootloader will work forever...

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Modifying source file TinyBld

Post by LubinKerhuel » Tue Jan 06, 2009 9:20 am

I have this .hex file (tinybld software) for dsPIC 4013 :
tinybld_ds30f4013_10MHz_HS_19200.zip
(12.52 KiB) Downloaded 621 times
(Quartz at 10Mhz, no PLL used, UART configuration at 19200)

crh
Posts: 20
Joined: Wed Oct 29, 2008 11:51 am

Re: Modifying source file TinyBld

Post by crh » Wed Jan 07, 2009 9:38 am

Hello Lubin,

Thank you very much for your provided hex file.
I assume that this hex file is working well, but still I have a problem to connect with my device with the max232.
I am so new in microcontrollers, that I even do not know if I wrote the hex file in a correct way to the device.
Therefor, you can find a screenprint of the GUI from Pickit2 and a screenprint from the max232 circuit.

Casparus
Attachments
circuit max232 to dspic30
circuit max232 to dspic30
screenprint GUI Pickit2 and GUI TinyBld
screenprint GUI Pickit2 and GUI TinyBld

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Modifying source file TinyBld

Post by LubinKerhuel » Wed Jan 07, 2009 10:13 am

No problems due to Vista with the COM port ?

crh
Posts: 20
Joined: Wed Oct 29, 2008 11:51 am

Re: Modifying source file TinyBld

Post by crh » Thu Jan 08, 2009 7:57 am

Hello Lubin,

Yesterday evening I tried to discover if it was a Vista problem and checked it with my old laptop running under Windows XP. But a pity: the same errors.
Still, I suppose it is more a hardware problem then a software problem. From the other hand, I have checked the circuitry a thousand times.
For your information, because I am not 100% sure if it is alright:
I connected:
pin 11 (TX) of the max232 with pin 28 of the pic (pin layout see image from yesterday) and
pin 12 (RX) of the max232 with pin 27 of the pic.
I do not use an external crystal.
In order to connect the max232 to my computer I use a Serial to USB Cable. But I wonder if I have to change some settings in my computer.

Kind Regards, Casparus

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Modifying source file TinyBld

Post by LubinKerhuel » Thu Jan 08, 2009 10:27 am

Hi Casparus,

I do not see errors on the Rx-Tx connections.
Using USB to Serial converter is not a problem.

To test your hardware, I would advise to create a simple schematic for you dsPIC with simulink, compile it and load it using your usual programmer (ICD2). You can use the windows HyperTerminal to check that you PC can transmit/receive data with the dsPIC through UART.

Anyway, you may have a serious problem because you do not use quartz: dsPIC Internal RC oscillator is usually not precise enough (and may vary over time) for UART set-up, except if you use the microchip system to auto calibrates the UART (see UART doc, not supported in the blockset).
Lubin

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests