Hello.  You should know that 14 bit core has only  8 bit stack levels. It's mean that the 14 bit core is C unfriendly. The 16 bit core or 18f4550 has 31 bit stack levels.

There are still a lack of documentation about the Sdcc port for pic. But i will try to show you something i have learned.

The header file of pic16f690 can tell you a lot of things that you must know to
programming the Pic uc.

   In the directory /usr/share/sdcc/include/pic/ you can find all the header file to the port14

In the pic16fxxx header file there are the special function registers and its bits.

RA0=0;
RA1=1;
PORTB=2;
GIE=0;


The sdcc can recognize  decimal , binary and hexadecimal  numbers. Ex:

PORTA=0xFF;              // PORTA=255
PORTA=0b11111111;  // PORTA=255
PORTA=255; // (default decimal)

Remember that C programming to mcu is not same as the C to intel x86.
There aren't the standard I/O library, printf , scanf ...

Its common to do the following:

There are the following data types that you must know to perform embedded system programmig:


char                          /   uint_8t:  8 bits     Range 0 to 255          
unsigned  char         /   int_8t   :  8 bits     Range -127 to 128     
unsigned int             /   uint_16t : 16 bits  Range 0 to 65535      
int                            /    int_16t  : 16 bits  Range ????
float                         /   float      :  32 bits                                     


==============

The SDCC compiler don't have a built-in delay routine like the CCS compiler  eg.:
#pragma use clock 40000.

void main{
      delay(500);
}

you should do it by yourself. 

==============

You must also know the bit-masks techniques :

Bitwise operatiors:

&     and operator
|       or   operator
~     not operator (inverter)
>>   left shift         
<<   right shift       
^      xor operator

CODE= PORTA &  0b10000011  ;  // Read the RA7, RA1 and RA0 bits

Ex  PORTA =      11001101
                      &   10000011   ( bit mask)
                           ------------------
                            10000001   (masked result)


Eg.: read the PORTA hight nibbles :
NIBBLES= PORTA >> 4;


Eg.: 
Blink all leds in PORTA.

CODE= 0b1111111;

while(1){
   PORTA=PORTA^CODE;
   delay_500();
}

....
....

==============================

You should avoid complex math and store constant data in program memory by storing the data on program memory (flash memory).

Note that __code directive forces the data to be stored in the flash memory( program memory).

Eg.:

#include <xxxx.h>
#define u8 char
.....



void main(){
 
       TRISA=0x00;
       PORTA=disp7seg(8);  // Display digit 8 on the seven segment display

}

#if 1
static u8    disp7seg(u8 digit){


        __code  u8 LookUpTable[10]={   // It is stored in the program memory __code
                0x3F,        // Disp 0
                0x06,        // Disp 1
                0x5B,        // Disp 2
                0X4F,        // Disp 3
                0x66,        // Disp 4
                0x6D,        // Disp 5
                0x7D,        // Disp 6
                0x07,        // Disp 7
                0x7F,        // Disp 8
                0x6F,        // Disp 9
                0x00        // Digito nulo se requerido
        };//End of LookUpTable


return LookUpTable[digit];
}
#endif



Excuse my English, it's not my native language,I  am from Brazil.

Best regards.

On 08/22/2010 11:44 PM, Bob Cochran wrote:
  Greetings,

I am a new SDCC user. I have succeeded in compiling, flashing and 
running a simple LED-blinking program for the PIC16F690 on a breadboard. 
I am new to embedded programming and very new to writing embedded C 
programs. I learned about SDCC in my search for an open source PIC 
device compiler.

Where can I find examples of C programs which are compiled on SDCC for 
the PIC14 port? I would like to study these so I can learn from more 
advanced programmers.

Thanks

Bob Cochran
Greenbelt, Maryland
USA


------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user