My experience with C is that as I build an application at some point it starts doing some very wierd stuff. Errors move and warnings change when you insert debug statements. This usually means that I am stepping on memory somewhere.
Is it possible to conclude that inserting debug statements could be moving the lines where your errors and warnings occur?
GCC has hundreds of command line options. Most of them are processor specific. Many however are generic optimization flags or warning enable/disable flags.
The most common command line options to be concerned with are in the Project Manager Compile and Linker settings tabs. I'm guessing a good service at this point would be to at least describe the flags that are used in the build process.
I personally prefer the Project mode (obviously), and can't stand the Simple view mode :P. I understand why it's there, but I don't have to like it or use it! Although, for the show I do switch back to that mode to check things.
Yeah, the problem as experienced in the podcast is that SimpleView hides the project infrastructure while providing project-level actions (Open, Save, etc.). Atdiy's question about the difference between a project and its code file shows how SimpleView leaves out an important layer in that infrastructure. Hopefully, that comes to light for users that move on to multi-source file projects, eventually.
But, I guess the idea is to get new users in a classroom environment up and running some code quickly and SimpleView is the "simplest" format to that end.
Keep up the good work in these podcasts. Having several levels of expertise in the podcast certainly brings to light issues and allows discussion of C coding realities and solutions!
I guess Simple View is useful as a one file program tool. To me just a little more effort to teach Project View would be better.
When modular library programming is being taught, students must use Project View ... before that is Ok too.The auto-include library feature should work fine with one file programs, but there is a point where creating libraries is useful.
Create Project Library allows turning a project with multiple C files into a library that can be added to the Simple Libraries. Once a library is included with proper naming, it can be auto-included too.
I strongly recommend version 0-9-43+ for library programming.
Welcome to the 9th episode of FirstC! This is a short podcast series to help beginner coders learn how to program in C on the Parallax Propeller! This week we address more questions/comments on the Parallax forums and also cover some of the saving “issues” that Addie encounters. We then go into functions and how powerful they can become.
1. That's what I was trying to say without being too over the head of newbs. Sometimes I struggle with explaining things, because if I get too detailed in my explanation, then I have to explain several other things. In this case, I tried to just explain it enough for the newb listener. Often time in the long run (in later shows), we'll hit the topic again and explain it more.
2. This is one I know, but never run into myself because in C++ foo() and foo(void) is the same thing and you still have type checking. Also, in the context of the Prop and Learn stuff it's not just not going to matter much.
3. Good to know there is supposed to be a built in delay so you don't need one at the start of your program. We'll mention it in the next show. Thanks!
j3. Good to know there is supposed to be a built in delay so you don't need one at the start of your program. We'll mention it in the next show. Thanks!
It only works for simpletext functions like print and putLine. The standard serial driver that gives printf does not provide any start up delay.
For the 'hello' example I would have set it up like so:
static void hello(void)
{
..
}
static void goodbye(void)
{
..
}
int main ..
the point being to use static functions as in the example all functions are local and private, and when that is combined with arranging the code bottom-up (code defined before usage) you get self-prototyping and don't have to explicitly add prototype declarations. You get smaller and well-organized source code. I only use explicit prototypes for local static functions if there's recursive or cross-calling going on, in other words almost never. I use non-static functions only when they're called from other source files, and in that case (i.e. always) the prototypes go into header files, not source files. In fact some compilers will give warnings if you add prototype declarations to source (.c) files, for example the Intel C compiler:
remark #1419: external declaration in primary source file
It only works for simpletext functions like print and putLine. The standard serial driver that gives printf does not provide any start up delay.
A startup delay is useful when you're using an IDE like SimpleIDE but it may not be what you want once you've finished developing your program and want to boot it directly from EEPROM. In that case, the delay serves no purpose other than slowing down program startup. Maybe it should be optional?
Welcome to the 10th episode of FirstC! This is a short podcast series to help beginner coders learn how to program in C on the Parallax Propeller! This week we address questions/comments on the Parallax forums again and then go into functions and functions with parameters. Roy helps Addie with some of the tutorial code and we talk briefly about stack overflows!
Thank you guys, This is awesome and really helps to understand the Prop chip, To me the Prop is like apple computers in the 90's, The best computers but without software or support giving gates the chance to swoop in and take over, Kinda like arduino... History repeats itself! Unfortunately most people don't care about 80MHz or 8 cogs, As long as they can understand and get it going fairly fast... I'm pretty sure though that now with C things are gonna change big time and will see more props at radioshack than arduinos whoo-hoo!
Thank you guys, This is awesome and really helps to understand the Prop chip, To me the Prop is like apple computers in the 90's, The best computers but without software or support giving gates the chance to swoop in and take over, Kinda like arduino... History repeats itself! Unfortunately most people don't care about 80MHz or 8 cogs, As long as they can understand and get it going fairly fast... I'm pretty sure though that now with C things are gonna change big time and will see more props at radioshack than arduinos whoo-hoo!
You're very welcome!! Glad you're learning more about the Propeller - . We're excited about how the focus of C will bring in new users! Do let us know if there's anything in particular you'd like us to cover as well.
Welcome to the 11th episode of FirstC! This is a short podcast series to help beginner coders learn how to program in C on the Parallax Propeller! This week we gab about the Micromedic competition and then go into global variables and using multiple cogs with C. A big leap but with a little explanation, we learn a lot this week!
Re: COGC mode speed and other modes.
1. COG mode "COGC" programs will run "on the metal" without any interpreter. That means full speed of course.
2. It is possible to run small functions (64 instructions or less) at full speed as well by tagging functions as __attribute__(fcache).
Re: Volatile
Volatile tells the Compiler not to optimize away some operation like read or write. It is often used in hardware device drivers.
Re: print delays
The print function does not actually have a startup delay. The delay is introduced one (and only one) time when simpletext/simple_serial is constructed at first program startup. And no, this will not be made optional. There should be no special print delays in multi-core code.
Re: Warnings
SimpleView programs do not enable warnings because that's what Parallax wanted.
I've recently added code to new Project View projects to always enable warnings and will be in release 0-9-44+.
Other multicore examples like use cognew to start a cog with PASM from a .spin or COGC from a .cogc file.
Advanced 1.0 expert+ example: Use cognew to start a cog with in-line assembly (see simpletools fpucog.c).
I'm available for forum Q&A if necessary.
Episode 10 Feedback:
Sorry, i fell asleep half-way through it ... it was late.
Suggestions for a future Podcast:
First of all, thank you for a great series on how to use C on the propeller. Even better, the discussions transcend beyond the propeller into the world of regular C. It has helped tremendously in my beginners understanding of how C works and why. Something I am hoping you will touch on in the near future is how to actually implement a C program that is made up of multiple .C files where functions are called across the multiple files. Some detail on how all the additional C files are incorporated into one functioning program would really be helpful. I remember reading on a Microchip forum where it was considered very bad form to actually #INCLUDE a .c file and that directive was meant for .h files. Any possibility we may hear you talk about this, with maybe some examples?
Hi Hal, I'll ask the senseis Whisker and Roy what they think I'm glad you've enjoyed the podcast and that it's helped your understanding! It's definitely helped mine haha, but I should hope so, otherwise I'm not asking the right questions! We'll address your comments next week but until then:
Welcome to the 12th episode of FirstC! This is a short podcast series to help beginner coders learn how to program in C on the Parallax Propeller! This week we go into sensors that are available from Parallax such as the Ping distance sensor and PIR motion detector! We cover an example that has the PIR sensor triggering the Ping sensor.
I don't favor the taste of pumpkin by itself, so to me whipped cream is absolutely necessary.
Whipped cream ruins the taste of a White Mocha Grande' though.
Here are some suggestions for getting around the noob == -vs- = problem:
1) use if(readonly == variable) rather than if(variable == readonly) such that "readonly" is a constant or function.
2) use != instead of == if possible.
Welcome to the 13th episode of FirstC! This is a short podcast series to help beginner coders learn how to program in C on the Parallax Propeller! This week we’re looking at how to use the 2-axis joystick with continuous rotation servos! We go through Addie’s step by step method of try-try-again .
Welcome to the 14th episode of FirstC! This is a short podcast series to help beginner coders learn how to program in C on the Parallax Propeller! This week we're looking at how to use the accelerometer and how to port Emic2 spin code into C using fdserial.h!
Thank you for your podcast! I have been using the Prop chip for a couple of years and also enjoyed your First C podcast. I also have a beginners experience with C, so the First C podcast has been a great help.
I have run into a problem. Have you tried to use the ramp feature of Servo.h, ramp does not effect the servos until the 2nd movement. See my code below:
int main() // main function
{
while(1)
{
servo_setramp(11, 10); // Set up ramp for servos
servo_setramp(10, 10);
servo_angle(11, 900); // Servos facing forward
servo_angle(10, 900);
pause(2000);
servo_angle(11, 1850); //Servos facing out
servo_angle(10, 0);
pause(2000);
}
}
Hey - thanks for the feedback (And good idea Jazzed! - if only I could get it more responsive/faster) Glad you like the show! I haven't used the ramp function yet but I could certainly try your code and see what's going on.
And we actually had some scheduling difficulties because of out of town visitors and with the holiday season, it may be a little bit before we have another episode - that just leaves me more time to get better code working!!
Comments
Is it possible to conclude that inserting debug statements could be moving the lines where your errors and warnings occur?
GCC has hundreds of command line options. Most of them are processor specific. Many however are generic optimization flags or warning enable/disable flags.
The most common command line options to be concerned with are in the Project Manager Compile and Linker settings tabs. I'm guessing a good service at this point would be to at least describe the flags that are used in the build process.
Yeah, the problem as experienced in the podcast is that SimpleView hides the project infrastructure while providing project-level actions (Open, Save, etc.). Atdiy's question about the difference between a project and its code file shows how SimpleView leaves out an important layer in that infrastructure. Hopefully, that comes to light for users that move on to multi-source file projects, eventually.
But, I guess the idea is to get new users in a classroom environment up and running some code quickly and SimpleView is the "simplest" format to that end.
Keep up the good work in these podcasts. Having several levels of expertise in the podcast certainly brings to light issues and allows discussion of C coding realities and solutions!
dgately
When modular library programming is being taught, students must use Project View ... before that is Ok too.The auto-include library feature should work fine with one file programs, but there is a point where creating libraries is useful.
Create Project Library allows turning a project with multiple C files into a library that can be added to the Simple Libraries. Once a library is included with proper naming, it can be auto-included too.
I strongly recommend version 0-9-43+ for library programming.
Episode Link: http://www.tymkrs.com/shows/episode/firstc-episode-009/
Parameters for main are optional in C. Applications use "int main(int argc, char* argv[])", but it is not required by the standard.
By not using void for a function without arguments, you lose function type checking.
There is a half-second delay during the serial port startup. Sound's like that should be a one second delay.
1. That's what I was trying to say without being too over the head of newbs. Sometimes I struggle with explaining things, because if I get too detailed in my explanation, then I have to explain several other things. In this case, I tried to just explain it enough for the newb listener. Often time in the long run (in later shows), we'll hit the topic again and explain it more.
2. This is one I know, but never run into myself because in C++ foo() and foo(void) is the same thing and you still have type checking. Also, in the context of the Prop and Learn stuff it's not just not going to matter much.
3. Good to know there is supposed to be a built in delay so you don't need one at the start of your program. We'll mention it in the next show. Thanks!
It only works for simpletext functions like print and putLine. The standard serial driver that gives printf does not provide any start up delay.
-Tor
Episode Link: http://www.tymkrs.com/shows/episode/firstc-episode-010/
Two Values: http://pastebin.com/eZ9w35hp
Function with parameter Try 1: http://pastebin.com/WaS25kak
Function with parameter Try 2: http://pastebin.com/qtsjUd2z
Function with parameter Try 3!: http://pastebin.com/vEdmFXsu
Function with parameter and Return: http://pastebin.com/e816qf3y
You're very welcome!! Glad you're learning more about the Propeller - . We're excited about how the focus of C will bring in new users! Do let us know if there's anything in particular you'd like us to cover as well.
Episode Link: http://www.tymkrs.com/shows/episode/firstc-episode-011/
Global Variables: http://pastebin.com/index/huarhAU3
Multi core Example: http://pastebin.com/0ZqPXKVW
Re: COGC mode speed and other modes.
1. COG mode "COGC" programs will run "on the metal" without any interpreter. That means full speed of course.
2. It is possible to run small functions (64 instructions or less) at full speed as well by tagging functions as __attribute__(fcache).
Re: Volatile
Volatile tells the Compiler not to optimize away some operation like read or write. It is often used in hardware device drivers.
Re: print delays
The print function does not actually have a startup delay. The delay is introduced one (and only one) time when simpletext/simple_serial is constructed at first program startup. And no, this will not be made optional. There should be no special print delays in multi-core code.
Re: Warnings
SimpleView programs do not enable warnings because that's what Parallax wanted.
I've recently added code to new Project View projects to always enable warnings and will be in release 0-9-44+.
Suggestions:
Explain Show Map File (Project Manager right-click filename -> popup -> "Show Map File"
Other multicore examples like use cognew to start a cog with PASM from a .spin or COGC from a .cogc file.
Advanced 1.0 expert+ example: Use cognew to start a cog with in-line assembly (see simpletools fpucog.c).
I'm available for forum Q&A if necessary.
Episode 10 Feedback:
Sorry, i fell asleep half-way through it ... it was late.
LOL.
First of all, thank you for a great series on how to use C on the propeller. Even better, the discussions transcend beyond the propeller into the world of regular C. It has helped tremendously in my beginners understanding of how C works and why. Something I am hoping you will touch on in the near future is how to actually implement a C program that is made up of multiple .C files where functions are called across the multiple files. Some detail on how all the additional C files are incorporated into one functioning program would really be helpful. I remember reading on a Microchip forum where it was considered very bad form to actually #INCLUDE a .c file and that directive was meant for .h files. Any possibility we may hear you talk about this, with maybe some examples?
Hal
Seminole, Fl
Welcome to the 12th episode of FirstC! This is a short podcast series to help beginner coders learn how to program in C on the Parallax Propeller! This week we go into sensors that are available from Parallax such as the Ping distance sensor and PIR motion detector! We cover an example that has the PIR sensor triggering the Ping sensor.
- Ping Sensor: http://pastebin.com/bGsm2K2u
- PIR Spin Code: http://pastebin.com/sdgWhYHU
- PIR + Ping: http://pastebin.com/udshGsbm
- Fixed PIR + Ping: http://pastebin.com/G0dfGFQr
Episode Link: http://www.tymkrs.com/shows/episode/firstc-episode-012/I don't favor the taste of pumpkin by itself, so to me whipped cream is absolutely necessary.
Whipped cream ruins the taste of a White Mocha Grande' though.
Here are some suggestions for getting around the noob == -vs- = problem:
1) use if(readonly == variable) rather than if(variable == readonly) such that "readonly" is a constant or function.
2) use != instead of == if possible.
Episode Link: http://www.tymkrs.com/shows/episode/firstc-episode-013/
Episode Link: http://www.tymkrs.com/shows/episode/firstc-episode-014/
I have run into a problem. Have you tried to use the ramp feature of Servo.h, ramp does not effect the servos until the 2nd movement. See my code below:
int main() // main function
{
while(1)
{
servo_setramp(11, 10); // Set up ramp for servos
servo_setramp(10, 10);
servo_angle(11, 900); // Servos facing forward
servo_angle(10, 900);
pause(2000);
servo_angle(11, 1850); //Servos facing out
servo_angle(10, 0);
pause(2000);
}
}
Hope the next podcast is soon!
And we actually had some scheduling difficulties because of out of town visitors and with the holiday season, it may be a little bit before we have another episode - that just leaves me more time to get better code working!!