sdcc | 1 Jul 2007 11:07
Picon

Re: pic16 adc libs

Claudia Ruch wrote:
> Hi Jan,
>  
> I write to you because I have a problem with the sdcc adc.h library. I
> am new to microcontroller programming and I am working at my diploma
> thesis at the University of Munich at the moment . I saw that there is a
> bug in this file because of the new adcon2 register. I use the pic
> 18f2550 and tried to correct the adc_open command but I did not
> succeed. Can you send me your improved files for ad conversion? Do you
> thing fosc/16 is okay for a 20MHz oscillator? Which aquisition time do
> you recommend?

My patch is only tested on the pic18fXXXX (pic18f2550 and pic18f4550).
On the pic18f1320 and pic18f1220 the library shipped with sddc did work
as far as i remember.

I'll attach the patch to this mail.

Greetings from Heidelberg

jan
>  
> It would help me a lot if you sent me your files.
>  
> Greetings form Munich
>  
> Claudia

Attachment (pic16_adc.diff): text/x-patch, 5949 bytes
(Continue reading)

Jonathan and Caroline Moore | 10 Jul 2007 12:09
Picon

Parameter passing problem

A nudge in the right direction to fix this much appreciated:

SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.5.6 # (Jun 14 2007) (UNIX)
gpasm-0.13.3 beta
gplink-0.13.3 alpha

Here is my program main.c

#include "pic18fregs.h"

#pragma stack 0x200 64

void ledon(void);
void addtask(int);

typedef struct t_tasks {
	void (*fp)();
};

struct t_tasks mytasks[2];

void main(void) {
	addtask(0);
}

void ledon(void) {
	PORTBbits.RB4 = 1;
}

(Continue reading)

Raphael Neider | 13 Jul 2007 10:30
Picon

Re: Parameter passing problem

Hi Jonathan,

Well, its a compiler bug. From line
    mytasks[a].fp = ledon;
SDCC generates something like

        MOVFF   LOW(_ledon), POSTINC0
        MOVFF   HIGH(_ledon), POSTINC0
        MOVFF   UPPER(_ledon), INDF0

This will push the contents of registers 0x1c, 0x02, and 0x00 into
mytasks[a], but we wanted to place the literal values 0x1c, 0x02, and
0x00 (= address of _ledon) there.

I fixed this in the latest svn revision (r4880). Please update and have
the following correct generated:
        MOVLW   LOW(_ledon)
        MOVWF   POSTINC0
        MOVLW   HIGH(_ledon)
        MOVWF   POSTINC0
        MOVLW   UPPER(_ledon)
        MOVWF   INDF0

Regards,
Raphael

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
(Continue reading)

sdcc | 18 Jul 2007 11:07
Picon

array initalisation

Hello,

I have a problem where i couldnt find a clear answer in the manual/list.
I want to initialize an 4x4 array like:

char state_table[4][4]={{0,1,-1,0},{-1,0,0,1},{1,0,0,-1},{0,-1,1,0}};
but this only works if i add the code keyword infront of it. If code is
omitted the array does not work.
Is this the intended behavior? or am i doing something wrong?

sdcc -v:  SDCC : pic16 2.6.4 #4631 (Feb 13 2007) (UNIX)
device: pic18f2550

thx allot in advance

jan

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Picon

Re: array initalisation

hi
it mite be possible that the capacity of UC's SRAM is low to store a hole program in it so when u add word "CODE" in front of it the part of  code gets store in Flash memory of ur UC...

On 7/18/07, sdcc-h/0poJquYq6c6c25WfRs7A@public.gmane.org <sdcc-h/0poJquYq6c6c25WfRs7A@public.gmane.org> wrote:
Hello,

I have a problem where i couldnt find a clear answer in the manual/list.
I want to initialize an 4x4 array like:

char state_table[4][4]={{0,1,-1,0},{-1,0,0,1},{1,0,0,-1},{0,-1,1,0}};
but this only works if i add the code keyword infront of it. If code is
omitted the array does not work.
Is this the intended behavior? or am i doing something wrong?

sdcc -v:  SDCC : pic16 2.6.4 #4631 (Feb 13 2007) (UNIX)
device: pic18f2550

thx allot in advance

jan








-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Sdcc-user mailing list
Sdcc-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/sdcc-user



--
Regards-----
Abhishek..
(M)+91 9820475899
(O)+91 22 25720700
www.triindia.co.in

http://abhishekworld.wordpress.com/
http://www.flickr.com/photos/abhishekworld/

/********************************************************************************/
  "Imagination is more important than  knowledge..."    Albert Einstein
                                                                                                    
/********************************************************************************/
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@...
https://lists.sourceforge.net/lists/listinfo/sdcc-user
Ernst Bachmann | 18 Jul 2007 14:02
X-Face
Picon

Re: array initalisation

On Mittwoch, 18. Juli 2007, sdcc@... wrote:

> I have a problem where i couldnt find a clear answer in the manual/list.
> I want to initialize an 4x4 array like:
>
> char state_table[4][4]={{0,1,-1,0},{-1,0,0,1},{1,0,0,-1},{0,-1,1,0}};
> but this only works if i add the code keyword infront of it. If code is
> omitted the array does not work.
> Is this the intended behavior? or am i doing something wrong?
>
> sdcc -v:  SDCC : pic16 2.6.4 #4631 (Feb 13 2007) (UNIX)
> device: pic18f2550

Well, that pic should have enough ram for the array, but:

if the Array is in RAM, the startup code has to initialize it by copying the 
values from Flash.
That is usually done by the initialization code in crt0iz.o, which should be 
linked automatically. 
There are however also other versions of that init code available (crt0i.o, 
crt0.o) which skip the variable initialization in order to save code space.

Check your makefiles if you're linking the right one.

/Ernst

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
sdcc | 18 Jul 2007 14:16
Picon

Re: array initalisation

Ernst Bachmann wrote:
> On Mittwoch, 18. Juli 2007, sdcc@... wrote:
> 
>> I have a problem where i couldnt find a clear answer in the manual/list.
>> I want to initialize an 4x4 array like:
>>
>> char state_table[4][4]={{0,1,-1,0},{-1,0,0,1},{1,0,0,-1},{0,-1,1,0}};
>> but this only works if i add the code keyword infront of it. If code is
>> omitted the array does not work.
>> Is this the intended behavior? or am i doing something wrong?
>>
>> sdcc -v:  SDCC : pic16 2.6.4 #4631 (Feb 13 2007) (UNIX)
>> device: pic18f2550
> 
> Well, that pic should have enough ram for the array, but:
> 
> if the Array is in RAM, the startup code has to initialize it by copying the 
> values from Flash.
> That is usually done by the initialization code in crt0iz.o, which should be 
> linked automatically. 
> There are however also other versions of that init code available (crt0i.o, 
> crt0.o) which skip the variable initialization in order to save code space.

yes crt0.z was used in my Makefile since i had some startup problem for
the USB Code with crt0i(z) while ago. It seems all to rune fine now with
crt0iz.
So what/where is the prefered location for putting arrays/structs
1. without any option?
2. with the code option?
3. or with the #pragma udata ... option?

thx allot for your effort.
jan

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Hynek Sladky | 20 Jul 2007 09:40
Picon
Favicon

Z80 and bitfields

I am new SDCC user and I have problem :-)

struct {
   unsigned int READ_BL_LEN:4;
   unsigned int CCC:12;
} CSD;

Accessing READ_BL_LEN is OK.
Accessing CCC is wrong. Is there any problem with bitfields or is my 
code wrong?

   printf ("RDlen=%d\n", CSD.READ_BL_LEN);
 >> ld	hl,#_CSD
 >> ...

   printf ("CCC=%03X\n", CSD.CCC);
 >> ld	bc,#_CSD + 1
 >> ld	l,c
 >> ld	h,b
 >> ld	a,(hl)
 >> ld	c,a
 >> inc	hl
 >> ld	a,(hl)
 >> and	a,#0x0F

It seems that second part of bitfield starts at next byte location from 
bit 0 :-(

Thanks.
Hynek Sladky

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Philipp Klaus Krause | 20 Jul 2007 09:53
Picon

Re: Z80 and bitfields


Hynek Sladky schrieb:

> It seems that second part of bitfield starts at next byte location from 
> bit 0 :-(

Why not? AFAIK the C standard doesn't guarantee alignment in bitfields,
it doesn't even guarantee alignment in structures.

Philipp

Hynek Sladky | 20 Jul 2007 10:30
Picon
Favicon

Re: Z80 and bitfields

But it is sometimes used for such purposes (defining e.g. HW register 
content - and I adopted it as well) so I don't understand why it is used 
such way if it is not guaranted... Is there correct way for it?

BTW - my structure works in all other compilers I have used.

Thanks,
Hynek Sladky

Philipp Klaus Krause napsal(a):
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hynek Sladky schrieb:
> 
> 
>>It seems that second part of bitfield starts at next byte location from 
>>bit 0 :-(
> 
> 
> Why not? AFAIK the C standard doesn't guarantee alignment in bitfields,
> it doesn't even guarantee alignment in structures.
> 
> Philipp

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Gmane