Editing BoostC Forum Extracts 2007
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 1: | Line 1: | ||
== Almost Ready For Reading == | == Almost Ready For Reading == | ||
+ | |||
* From: http://forum.sourceboost.com/index.php?showtopic=3444&pid=12904&mode=threaded&start=#entry12904 | * From: http://forum.sourceboost.com/index.php?showtopic=3444&pid=12904&mode=threaded&start=#entry12904 | ||
A macro like MAKESHORT can initialize a variable but the compiler does not know that and generates a warning. Is there a way to solve this without initializing the variable explicitly? | A macro like MAKESHORT can initialize a variable but the compiler does not know that and generates a warning. Is there a way to solve this without initializing the variable explicitly? | ||
+ | |||
u16_t timestamp; | u16_t timestamp; | ||
Line 16: | Line 18: | ||
I am not an expert, but I think I have seen compilers that have pragma's that give hints to compiler about these things. | I am not an expert, but I think I have seen compilers that have pragma's that give hints to compiler about these things. | ||
− | |||
* From: http://forum.sourceboost.com/index.php?showtopic=3430&pid=12890&mode=threaded&start=#entry12890 | * From: http://forum.sourceboost.com/index.php?showtopic=3430&pid=12890&mode=threaded&start=#entry12890 | ||
Line 31: | Line 32: | ||
"0123456789", quuuux | "0123456789", quuuux | ||
}; | }; | ||
+ | |||
I can create a two dimensional array of strings and initialize them or a array of enums and initialize them but not an array of structs. | I can create a two dimensional array of strings and initialize them or a array of enums and initialize them but not an array of structs. | ||
Line 46: | Line 48: | ||
doesn't work. | doesn't work. | ||
− | I believe you're going to have to assign the values yourself. I'd say use an inline function or something to make it look neater: | + | I can't find the thread I'm thinking of but I believe you're going to have to assign the values yourself. I'd say use an inline function or something to make it look neater: |
struct thing { | struct thing { | ||
Line 68: | Line 70: | ||
Found the thread - http://forum.sourceboost.com/index.php?showtopic=3404 | Found the thread - http://forum.sourceboost.com/index.php?showtopic=3404 | ||
+ | ----- | ||
− | + | break this into 3 | |
* From: http://forum.sourceboost.com/index.php?showtopic=3440&pid=12882&mode=threaded&start=#entry12882 | * From: http://forum.sourceboost.com/index.php?showtopic=3440&pid=12882&mode=threaded&start=#entry12882 | ||
Line 77: | Line 80: | ||
Prototypes are required if you do a forward reference to a function. If you are in the habit of using them, then always use them. I do. | Prototypes are required if you do a forward reference to a function. If you are in the habit of using them, then always use them. I do. | ||
− | |||
− | |||
** Question 2: | ** Question 2: | ||
Line 86: | Line 87: | ||
delay_ms(1000 ); | delay_ms(1000 ); | ||
− | I get no warnings. | + | I get no warnings. |
+ | |||
+ | Is there a way to make it more strict? | ||
If you go to Settings - Options and enable All warnings the compiler will warn you if you exceed 255 for a delay. | If you go to Settings - Options and enable All warnings the compiler will warn you if you exceed 255 for a delay. | ||
− | |||
− | |||
** Question 3: | ** Question 3: | ||
Line 97: | Line 98: | ||
There is no default interrupt handler that I can see. Keep GIE = 0 if you don't want you program to go into the woods. | There is no default interrupt handler that I can see. Keep GIE = 0 if you don't want you program to go into the woods. | ||
+ | |||
+ | |||
+ | ------ | ||
** Question 4: | ** Question 4: | ||
Line 106: | Line 110: | ||
− | |||
------------- | ------------- | ||
+ | |||
+ | |||
* From: http://forum.sourceboost.com/index.php?showtopic=3427&pid=12856&mode=threaded&start=#entry12856 | * From: http://forum.sourceboost.com/index.php?showtopic=3427&pid=12856&mode=threaded&start=#entry12856 | ||
Line 115: | Line 120: | ||
− | + | ||
* From: http://forum.sourceboost.com/index.php?showtopic=3431&pid=12843&mode=threaded&start=#entry12843 | * From: http://forum.sourceboost.com/index.php?showtopic=3431&pid=12843&mode=threaded&start=#entry12843 | ||
Line 130: | Line 135: | ||
− | |||
* From: http://forum.sourceboost.com/index.php?showtopic=3424&pid=12822&mode=threaded&start=#entry12822 | * From: http://forum.sourceboost.com/index.php?showtopic=3424&pid=12822&mode=threaded&start=#entry12822 | ||
− | notes that I am not able to summarize about structs union and access of sub-components | + | |
+ | notes that I am not able to summarize about structs union and access of sub-components. | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
----------------- | ----------------- | ||
+ | |||
+ | |||
*From: http://forum.sourceboost.com/index.php?showtopic=3416&pid=12807&mode=threaded&start=#entry12807 | *From: http://forum.sourceboost.com/index.php?showtopic=3416&pid=12807&mode=threaded&start=#entry12807 | ||
− | Best Method For Accumulated Timer -- | + | Best Method For Accumulated Timer -- go read it |
+ | |||
----------- | ----------- | ||
− | + | http://forum.sourceboost.com/index.php?showtopic=3408&pid=12790&mode=threaded&start=#entry12790 | |
− | + | go read it | |
+ | |||
+ | may be useful for lcd read and other ? | ||
+ | Here is my basic template when working with the 684 chip. | ||
+ | |||
+ | |||
+ | It may be of some help to you...... | ||
+ | |||
+ | LCD_684.txt ( 4.03K ) Number of downloads: 41 | ||
=== more === | === more === | ||
− | + | http://forum.sourceboost.com/index.php?showtopic=3411&pid=12788&mode=threaded&start=#entry12788 | |
− | + | ||
+ | |||
+ | |||
+ | hallo... | ||
+ | how do i measure the eact timing on my code using boostc? | ||
+ | even it have speed tester, but it dont show in time base.... | ||
+ | and how do i measure my the time of my desired code? Interested in advertising here? Contact support@sourceboost.com | ||
+ | |||
+ | |||
− | |||
− | + | set breakpoints in the debugger at the beginning and end of the code you want to evaluate. | |
in the debugger you can see the amount of ticks. so when you let it run from breakpoint to breakpoint you are able to see how manny ticks it took. If I don't oversee something here ( ) this should be a working method to determine the exact time it takes to run that peace of code..... | in the debugger you can see the amount of ticks. so when you let it run from breakpoint to breakpoint you are able to see how manny ticks it took. If I don't oversee something here ( ) this should be a working method to determine the exact time it takes to run that peace of code..... | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Reynard Dec 17 2007, 12:44 PM | ||
+ | Pos | ||
+ | |||
+ | |||
+ | QUOTE (fred @ Dec 16 2007, 11:30 PM) | ||
+ | set breakpoints in the debugger at the beginning and end of the code you want to evaluate. | ||
+ | in the debugger you can see the amount of ticks. so when you let it run from breakpoint to breakpoint you are able to see how manny ticks it took. If I don't oversee something here ( ) this should be a working method to determine the exact time it takes to run that peace of code..... | ||
+ | |||
A tick appears to be an oscillator cycle. If you step through a 1 cycle instruction it will increment the tick count by 4. A 4MHz xtal will give 1us instruction cycle time. | A tick appears to be an oscillator cycle. If you step through a 1 cycle instruction it will increment the tick count by 4. A 4MHz xtal will give 1us instruction cycle time. | ||
The tick count will change to values in 'kilo' after a while i.e. 10k etc. which cannot be reset to zero. | The tick count will change to values in 'kilo' after a while i.e. 10k etc. which cannot be reset to zero. | ||
− | |||
− | |||
If you install BoostC within MPLab (Microchip IDE) you can use its watchdog feature measure in real time. | If you install BoostC within MPLab (Microchip IDE) you can use its watchdog feature measure in real time. | ||
+ | -------- | ||
− | + | http://forum.sourceboost.com/index.php?showtopic=3410&pid=12768&mode=threaded&start=#entry12768 | |
− | |||
As has been pointed out, you should have i != 100 and i++. But in general, it's said to be safer to use "<" than "!=" in such a loop as it can prevent infinite loops if the "i" gets changed somewhere else in the loop. | As has been pointed out, you should have i != 100 and i++. But in general, it's said to be safer to use "<" than "!=" in such a loop as it can prevent infinite loops if the "i" gets changed somewhere else in the loop. | ||
Line 174: | Line 212: | ||
If you KNOW that the loop is going to be executed at least once, you are better off using the following: | If you KNOW that the loop is going to be executed at least once, you are better off using the following: | ||
− | + | i = 0; | |
− | + | do { /* loop contents */ } while ( ++i != 10 ); | |
Or if "i" is ONLY used as a counter, the following can be better still: | Or if "i" is ONLY used as a counter, the following can be better still: | ||
− | + | i = 10; | |
− | + | do { /* loop contents */ } while ( --i != 0 ); | |
Both can produce shorter, faster code! | Both can produce shorter, faster code! | ||
+ | Orin. | ||
------------ | ------------ | ||
− | + | ||
+ | http://forum.sourceboost.com/index.php?showtopic=3405 | ||
You can't cast rom to not-rom types or vice versa. I'd either do 2 switch constructions: one for rom and another for not-rom arrays or use a buffer where rom arrays will be copied before use. | You can't cast rom to not-rom types or vice versa. I'd either do 2 switch constructions: one for rom and another for not-rom arrays or use a buffer where rom arrays will be copied before use. | ||
Line 197: | Line 237: | ||
Russ | Russ | ||
− | |||
− | + | ----- | |
+ | http://forum.sourceboost.com/index.php?showtopic=3404&pid=12741&mode=threaded&start=#entry12741 | ||
I have a structure: | I have a structure: | ||
− | + | typedef struct | |
− | + | { | |
− | + | unsigned int A; | |
− | + | unsigned int B; | |
− | + | unsigned int c; | |
− | + | } ConvertCoeff; | |
and I declare an array of this structure: | and I declare an array of this structure: | ||
− | + | ConvertCoeff coeff[8]; | |
− | As long as I leave it this way everything is OK. But if I try to intialize the array during decleration as follows: | + | As long as I leave it this way everything is OK. |
+ | But if I try to intialize the array during decleration as follows: | ||
− | + | ConvertCoeff coeff[3] = { {1,2,3}, {1,2,3}, {1,2,3}}; | |
+ | |||
+ | I get an error during compilation - missing semicolon. | ||
+ | |||
+ | Is it not a legitimate initialization? I know it is possible on other compilers - how do I do it in BoostC? | ||
− | |||
− | + | As you said it appears that BoostC does not like initialising structures like other compilers. | |
+ | |||
+ | You will have to fill your structure the hard way. | ||
+ | |||
+ | ------------- | ||
− | + | http://forum.sourceboost.com/index.php?showtopic=3403&pid=12735&mode=threaded&start=#entry12735 | |
− | |||
the linker generates a serious stack warning because I have a function which is called within the handling of a rb0 interrupt and also in the program main loop. I can imagine that this can cause problems when the function is called by the interrupt routine and within the main() loop at the same time. | the linker generates a serious stack warning because I have a function which is called within the handling of a rb0 interrupt and also in the program main loop. I can imagine that this can cause problems when the function is called by the interrupt routine and within the main() loop at the same time. | ||
Line 235: | Line 282: | ||
If you are sure you are handling this situation correctly you can ignore this warning, your code looks like it maybe ok, but this kind of code can be tricky to understand. | If you are sure you are handling this situation correctly you can ignore this warning, your code looks like it maybe ok, but this kind of code can be tricky to understand. | ||
+ | -------- | ||
− | + | http://forum.sourceboost.com/index.php?showtopic=3269&pid=12715&mode=threaded&start=#entry12715 | |
− | |||
Yes, this one bit me too! I wrote the following routine that you can use for any ms value from 1 to 65535. I timed it at 60,000 and it seems to be pretty much on the money. | Yes, this one bit me too! I wrote the following routine that you can use for any ms value from 1 to 65535. I timed it at 60,000 and it seems to be pretty much on the money. | ||
− | + | void delayMs(unsigned int ms){ | |
− | + | char i; | |
− | + | char high = ms >> 8; | |
− | + | char low = ms & 0x00ff; | |
− | + | for(i = 0; i < high; i++){ | |
− | + | delay_ms(255); | |
− | + | } | |
− | + | delay_ms(low); | |
− | + | } | |
You might think that it needs another delay_ms(1) in the loop but I got the most accurate time without it. | You might think that it needs another delay_ms(1) in the loop but I got the most accurate time without it. | ||
Line 255: | Line 302: | ||
------------ | ------------ | ||
+ | |||
+ | v | ||
+ | |||
Is it possible for lprintf to write a substring to the lcd? | Is it possible for lprintf to write a substring to the lcd? | ||
Line 263: | Line 313: | ||
+ | Use | ||
+ | CODE | ||
+ | ... | ||
+ | lcd_datamode(); | ||
+ | char c, i; | ||
+ | for( i = 0; i < 16; i++ ) | ||
+ | { | ||
+ | c = buffer[i]; | ||
+ | if( c == 0 ) | ||
+ | break; | ||
+ | lcd_write( c ); | ||
+ | } | ||
+ | ... | ||
− | + | Regards | |
− | + | Dave | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
------------- | ------------- | ||
− | + | http://forum.sourceboost.com/index.php?showtopic=3367&pid=12653&mode=threaded&start=#entry12653 | |
+ | @Pavel: | ||
That's it. Adding -d DEBUG to the compiler options does exactly what I want. | That's it. Adding -d DEBUG to the compiler options does exactly what I want. | ||
Line 290: | Line 344: | ||
------- | ------- | ||
+ | === stop at === | ||
− | + | Counting Optimization (decfsz) | |
− | + | 1 Thompson 409 18th November 2007 - 07:22 PM | |
− | + | Last post by: Pavel | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | ( | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |