Thanks a lot for this detailed answer, I'm going to try this !

Le 24 janv. 2014 à 19:33, Gál Zsolt a écrit :

Sometimes it helped me ( including this function into my source code ):

void _sdcc_gsinit_startup(void)
{
  __asm pagesel _main __endasm;
  __asm goto _main __endasm;
}

https://www.mail-archive.com/sdcc-user@lists.sourceforge.net/msg03808.html

I tried your code and I see that the compiled code is ok. So I think the problem could be at initializing. 

;--------------------------------------------------------
                                           STARTUP	code 0x0000
000000   0000     nop                      	nop
                                           	pagesel __sdcc_gsinit_startup
000001   2802     goto    0x2              	goto	__sdcc_gsinit_startup
                                           ;--------------------------------------------------------
                                           ; code
                                           ;--------------------------------------------------------
                                           code_proba	code
                                           ;***
                                           ;  pBlock Stats: dbName = M
                                           ;***
                                           ;entry:  _main	;Function start
                                           ; 2 exit points
                                           ;has an exit
                                           ;; Starting pCode block
                                           _main	;Function start
                                           ; 2 exit points
                                           ;	.line	6; "./proba.c"	TRISB = 0;
0000d2   1683     bsf     0x3, 0x5         	BANKSEL	_TRISB
0000d3   1303     bcf     0x3, 0x6         
0000d4   0186     clrf    0x6              	CLRF	_TRISB
                                           ;	.line	7; "./proba.c"	PORTB = 59;     
0000d5   303b     movlw   0x3b             	MOVLW	0x3b
0000d6   1283     bcf     0x3, 0x5         	BANKSEL	_PORTB
0000d7   1303     bcf     0x3, 0x6         
0000d8   0086     movwf   0x6              	MOVWF	_PORTB
                                           _00106_DS_
                                           ;	.line	9; "./proba.c"	while(1)     
0000d9   28d9     goto    0xd9             	GOTO	_00106_DS_
0000da   0008     return                   	RETURN	


I recommend you use configuration word for set your device configuration bits.

for example:

/* ----------------------------------------------------------------------- */
/* Template source file generated by piklab */
#include <pic16f690.h>

/* ----------------------------------------------------------------------- */
/* Configuration bits: adapt to your setup and needs */
typedef unsigned int word;
word __at 0x2007 CONFIG = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON;

I don't understand the first line in your code:

#define __16f872

I think, SDCC does not require this.


2014/1/23 Ael Gain <ael.gain@free.fr>
Hi,

I set the config register in the software programmer, i've choosen the same config for the sdcc et mikroC .hex.

However, I forgot to mention that I have those warning during the build :

sdcc -mpic14 -p16f872 --use-non-free test2.c
test2.asm:145:Message[312] Page or Bank selection not needed for this device.  No code generated.
message: using default linker script "/usr/local/share/gputils/lkr/16f872_g.lkr"
warning: relocation of section "UDL_idata_0" failed, relocating to a shared memory location
warning: relocation of section "ID_idata_0" failed, relocating to a shared memory location

I think I read somewhere that this should not be a problem, but is this really ok ? I'm not sure to understand those warnings.

Le 22 janv. 2014 à 22:56, Joel Davidson a écrit :

> Ael-
>
> It looked like your source code was missing the config register
> information, which sets up the internal oscillator, reset operation,
> etc.  Perhaps the other compiler did that automatically?
>
> Joel
>
> On Wed, 22 Jan 2014, it would appear that Ael Gain wrote:
>
>> Thanks for your quick answer!
>>
>> Actually I tried to simulate the sdcc .cod file with gpsim and it worked ok.
>> I also tried to compare .hex files with gpdasm but couldn't find what can be wrong with the sdcc's one.
>> I guess I should give it another try.
>>
>> Is there any tools that simulate PIC's behaviour from .hex files ?
>> I mean a tool that shows content of registers and memory at a particular point of the program, and the flow of executed instructions ?
>> For my simple program i'll try to do it by hand, but for larger program it could be usefull.
>>
>> thx !
>>
>> Le 22 janv. 2014 ? 22:11, Bodo Wenzel a ?crit :
>>
>>> Hi Ael,
>>>
>>> Assuming that you are trying to gain some experience, I'd recommend to
>>> look into the assembler listings of both programs. If there is no
>>> listing you have to disassemble.
>>>
>>> Armed with the datasheet you will be able to investigate the problem.
>>>
>>> Good luck!
>>> Bodo
>>>
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For
> Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user



--
~~~~~~~~~~~~~~~~
http://galzsolt.zzl.org
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user