Editing BoostC tiny Wiki

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 16: Line 16:
 
===Go to [[PIC Links]]===
 
===Go to [[PIC Links]]===
 
Go to and search ( page search not google ) on "BoostC". There are projects, tips, tutorials.....  
 
Go to and search ( page search not google ) on "BoostC". There are projects, tips, tutorials.....  
=== [[BoostC Inline Functions]] ===
 
=== [[How the BoostC Compiler Works]] ===
 
 
 
=== [[BoostC Explaining Dot H Files]] ===
 
=== [[BoostC Wiki Help Needed]] ===
 
 
 
 
=== and even more comming soon.....===
 
=== and even more comming soon.....===
  
Line 59: Line 51:
  
 
This may be standard C or just BoostC, but type checking is not as strict as languages like Java.  Especially be careful of the idea that booleans and numbers are interchangable.  Especially do not think that 0 is false and 1 is true.  You can count on 0 being false ( I think )  I have seen test_bit evaluate to 64.
 
This may be standard C or just BoostC, but type checking is not as strict as languages like Java.  Especially be careful of the idea that booleans and numbers are interchangable.  Especially do not think that 0 is false and 1 is true.  You can count on 0 being false ( I think )  I have seen test_bit evaluate to 64.
 
=== Read Before Write Problems ===
 
 
[[Read before write]]
 
  
 
=== BootLoader Madness ===
 
=== BootLoader Madness ===
Line 68: Line 56:
 
Had a program, programmed with a programmer, worked fine.  Added a bootloader, bootloaded the program, NG.  Why why why!
 
Had a program, programmed with a programmer, worked fine.  Added a bootloader, bootloaded the program, NG.  Why why why!
  
Some hints, the fuses are inherited from the bootloader, your program cannot change, but that is not what got me.  I did not use, set, or enable interrupts.  This defult worked fine, but the bootloader apparently did not leave the settings in the default condition.  My fix, added an interrupt handler which did nothing, but even more important turned the global interrupts off at the very beginning of my program.  Not all bootloaders may behave in this way, but if you have a problem, consider the above. See also:  [[PIC Programmers, In Circuit Programming and BootLoaders]]
+
Some hints, the fuses are inherited from the bootloader, your program cannot change, but that is not what got me.  I did not use, set, or enable interrupts.  This defult worked fine, but the bootloader apparently did not leave the settings in the default condition.  My fix, added an interrupt handler which did nothing, but even more important turned the global interrupts off at the very beginning of my program.  Not all bootloaders may behave in this way, but if you have a problem, consider the above.
 
 
=== Include the Library ===
 
 
 
Normally the compiler will find the library file needed, but if you get messages that functions are not found include the library that contains them, see the .h file with the same name for the library function.  This has been know to work with the EEProm Library.  Choose the right one, for the 18F or 16F if there is a choice.
 
 
 
=== How to use PIC registers as C variables ===
 
 
 
BoostC compiler can map C variables on specific addresses. This becomes handly when one wants to use PIC registers as C variables. For example PIC CCPR1L and CCPR1H are a consecutively addressed register pair.
 
 
 
  volatile unsigned short ccpr1 @ 0xFBE; //declare a 16 bit variable that is located at address 0xFBE, just where CCPR1 registers start
 
  //Now this variable can be used in C cone
 
  ccpr1 = 0x2400; //for example assign 0x2400 to it what writes 0x00 into CCPR1L and 0x24 into CCPR1H
 
  
 
== Standard C Issues ==
 
== Standard C Issues ==
Line 126: Line 102:
  
 
In the good "old days" of the PDP-11 where large memory was measured in killobytes it was necessary to conserve memory -- even at the source code level.  In the 21st century environment of gigabyte memories it's no longer necessary to conserve bytes at the expense of readability and clarity.  Many programmers (particularly the old grumpy ones) take pride in saving a few bytes -- but mostly its a tradition thing except where the shortcuts save a bit of program run time.  ....but then there might be a reason why they call it 'code'.
 
In the good "old days" of the PDP-11 where large memory was measured in killobytes it was necessary to conserve memory -- even at the source code level.  In the 21st century environment of gigabyte memories it's no longer necessary to conserve bytes at the expense of readability and clarity.  Many programmers (particularly the old grumpy ones) take pride in saving a few bytes -- but mostly its a tradition thing except where the shortcuts save a bit of program run time.  ....but then there might be a reason why they call it 'code'.
 
Keep in mind that the following two sections are not equal. While the first looks neater at the source code level, it generates many times(!) more (redundant) machine instructions than the second form.
 
 
 
    bit LED1_TRIS        @ TRISB.5;
 
    bit LED2_TRIS        @ TRISB.6;
 
    bit LED3_TRIS        @ TRISB.4;
 
   
 
    LED1_TRIS = LED2_TRIS = LED3_TRIS = 0; // make output
 
 
 
Writing it this way, generates smaller and faster code:
 
 
    bit LED1_TRIS        @ TRISB.5;
 
    bit LED2_TRIS        @ TRISB.6;
 
    bit LED3_TRIS        @ TRISB.4;
 
   
 
    // make output
 
    LED1_TRIS = 0;
 
    LED2_TRIS = 0;
 
    LED3_TRIS = 0;
 
  
 
==== Read This ====
 
==== Read This ====
Line 202: Line 157:
 
== Code Snips that may Be Helpful ==
 
== Code Snips that may Be Helpful ==
  
 +
You are counting down and want to know when an unsigned number goes negative ( never ).  You could declare it signed, slowing everything down.  Instead check against FF.  This assumes you do not use FF on the positive side.  It also assumes you are counting down by one, else you could skip over FF.
  
moved to and merged with [[Index of sample code pages]]
+
  if ( 0xFF == ix ) ..
  
 
== Example Programs and Projects ==
 
== Example Programs and Projects ==
Line 223: Line 179:
 
* [http://en.wikibooks.org/wiki/C_programming Wikibooks: C programming] is about C programming in general (alas, focuses on programs running on desktop computers, rather than small microcontrollers).
 
* [http://en.wikibooks.org/wiki/C_programming Wikibooks: C programming] is about C programming in general (alas, focuses on programs running on desktop computers, rather than small microcontrollers).
  
* Gooligum C Tutorials [http://www.gooligum.com.au/tut_midrange_C.html ] C language Tutorials for mid range PICs with extensive examples and detailed explanations.  Written for HITEC and PICC but easily convertable to SourceBoost C.
 
 
[[Category:BoostC]][[Category:PIC]]
 
[[Category:BoostC]][[Category:PIC]]

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)