programming my own C file

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
ken
Posts: 1
Joined: Fri Jun 30, 2006 3:47 pm
Contact:

programming my own C file

Post by ken »

Hello, I am using the version 3 development board for the PICmicro (chip 16F84A) and the Sourceboost program. The tutorial program that comes with it simply turns SA0 on when SB0 is pressed. It works fine, I, however, am a beginner at this and wanted to program so that SA0 - SA4 would light up when SB0 is pressed. However, when I build the file compile, assemble, and program it keeps programming the previous file that only lights LED SB0. I've read through the "user manual" and I don't see anywhere how to make your own code and have it programmed into the Pic. Is there any help on the steps to do so, so when I go through this tutorial I can make changes to see the different results? Thanks for the help!

Below is the code I am trying to program into the chip

void main ( void )
{
set_tris_a (0x00) ; /* set bit 0 of PORTA for output */
set_tris_b (0xff) ; /* set all of PORTB for input */

while ( 1 ) { /* loop forever */
if ( input_pin_port_b ( 0 ) ) { /* check the input on PORTB */
output_high_port_a ( 0 ) ; /* light on if input */
output_high_port_a ( 1 ) ;
output_high_port_a ( 2 ) ;
output_high_port_a ( 3 ) ;
output_high_port_a ( 4 ) ;

}
else {
output_low_port_a ( 0 ) ; /* light off if no input */
output_low_port_a ( 1 ) ;
output_low_port_a ( 2 ) ;
output_low_port_a ( 3 ) ;
output_low_port_a ( 4 ) ;
}
}
}

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Your program seems correct, so it is definitely a problem with SourceBoost looking at the existing 'c' program rather than your new one.

One way around this would be to start from scratch. Open SourceBoost and select Project...New to create a new project. That way, the file you compile will definitely be yours rather than an existing one. You will be able to copy and paste your source code into this new project.

I hope this sets you down the correct path.

Post Reply