sdcc

Code Banking with SDCC

I need to use code banking in an 8051 microcontroller to fit all the code. SDCC says it supports it, but I'm having trouble at the linking step. I have a test project with 3 files: main.c, func1.c, and bank.asm. The main function should call func1() and then sit in a while loop. But func1() is in a different code bank. // main.c int...

What is wrong with this arithmetic when using SDCC (Little Endian) Compiler?

I am very new at C programming and I am working on a firmware application for my MCU. This method was working fine when I was using the KEIL compiler (Big Endian) but when I switched to the SDCC compiler (Little Endian) it is not working properly. Can someone please explain what I am doing wrong??? The target device is a Silicon Labs C8...

Do all C compilers allow functions to return structures?

I am working on a program in C and using the SDCC compiler for a 8051 architecture device. I am trying to write a function called GetName that will read 8 characters from Flash Memory and return the character array in some form. I know that it is not possible to return an array in C so I am trying to do it using a struct like this: //*...

Why does using a structure in C program cause Link error

I am writing a C program for a 8051 architecture chip and the SDCC compiler. I have a structure called FilterStructure; my code looks like this... #define NAME_SIZE 8 typedef struct { char Name[NAME_SIZE]; } FilterStructure; void ReadFilterName(U8 WheelID, U8 Filter, FilterStructure* NameStructure); int main (void) { FilterStru...

Ways to divide the high/low byte from a 16bit address?

Hello, I'm developing a software on 8051 processor. A frequent job is to divide the high and low byte of a 16bit address. I want to see there are how many ways to achieve it. The ways I come up so far are: (say ptr is a 16bit pointer, and int is 16bit int) [note the rn and arn is registers] bitwise operation ADDH = (unsigned int) ptr ...

How do you control what your C compiler Optimizes?

I am writing the firmware for an embedded device in C using the Silicon Labs IDE and the SDCC compiler. The device architecture is based on the 8051 family. The function in question is shown below. The function is used to set the ports on my MCU to drive a stepper motor. It gets called in by an interrupt handler. The big switch statemen...

Problem using SDCC in a Makefile during the link step

The Small Device C Compiler (SDCC) will produce a ihx (Intel Hex) file even if there are undefined reference errors during the link step. This behavior causes problems when using SDCC in a Makefile because if you set the ihx file to be your make target, then make has no good way of knowing that a previous attempt at linking has failed. ...