Jump to content
Sign in to follow this  
tedlarson

Can't even get a simple program to work...

Recommended Posts

I just downloaded C2C.  I wrote a simple test program just to get started....just to flash a couple of LED's on pins hanging off of portb.  Anyway, it doesn't work.  The process I used was, I compiled the 'C' program using PicAnt, and then loaded the ASM into MPLAB 6.2, assembled it, and then wrote it to a PIC16F84A.  I am using a PICStart Plus programmer, and I am used to programming PIC's using MPLAB's programming interface.  I couldn't find a command line interface to the PICStart Plus to get the full integration with PicAnt working.

 

Can someone tell me what I am doing wrong?  I have attached my sample program.

 

Thanks,

 

- Ted

 

-----------------------

#include

#pragma CLOCK_FREQ 2000000

main()

{

   disable_interrupt( GIE );

   trisb = 0;

   portb = 0;

 

   while( 1 )

   {

       portb = 0;

       delay_ms( 800 );

       portb = 255;

       delay_ms( 800 );

   }

}

Share this post


Link to post
Share on other sites

Ted,

 

select 16F84 from "Setting ---> Target ---> 16F84" and try with this code. Next, check with an oscilloscope if delays are correct.

 

#include "system.h"

#pragma CLOCK_FREQ 2000000

main()

{

  disable_interrupt( GIE );

  trisb = 0;

  portb = 0;

 

  while( 1 )

  {

      portb = 0;

      delay_ms(250);

      delay_ms(250);

      delay_ms(250);

      delay_ms(50);

      portb = 255;

      delay_ms(250);

      delay_ms(250);

      delay_ms(250);

      delay_ms(50);

  }

}

 

Best Regard;

Joan :laugh:

Share this post


Link to post
Share on other sites

Thanks for the replies.  I am pretty sure its not the configuration word...that was the first thing I checked.  Also, to make sure they weren't inconsistent between MPLAB and PicAnt. I am using a 20mhz ceramic oscillator, so my clocking needs to be HS, and I also made sure PIC16F84A was selected in both programs.

 

Still no luck with your program Joan.  I also tried it with the PIC16F84 selected instead of the A...no luck there either.

 

The following piece of assembly works correctly when compiled and programmed from MPLAB, so I know it is not my circuit, nor my programmer.  I can't help but wonder if something is getting messed up between PicAnt and MPLAB.  I couldn't figure out the command line to get the MPLAB to program the chip from within PicAnt.  I looked at the assembly output of the compiler, but couldn't determine what might be wrong.

 

Thanks,

 

- Ted

 

----this works------

include "p16F84a.inc"

 

ncount equ 0x0d

mcount equ 0x0e

f equ 1

 

list P=16F84A

org 0x00

goto START

 

START bsf STATUS,5

 

movlw B'00011111'

tris PORTA

 

movlw B'00000000'

tris PORTB

 

movlw B'00000111'

option

 

bcf STATUS,5

clrf PORTA

clrf PORTB

 

BEGIN bsf PORTB,1

call delay

call delay

bsf PORTB,2

call delay

bcf PORTB,1

call delay

call delay

bcf PORTB,2

call delay

 

GOTO BEGIN

 

;delay loop

delay     movlw   0xff

           movwf   mcount

loadn     movlw   0xff

           movwf   ncount

repeat  decfsz  ncount,f

       goto    repeat

       decfsz  mcount,f

       goto    loadn

       return

END

Share this post


Link to post
Share on other sites
Guest moyoyoyo

I'm new to this thing and I encounter a similar problem. I copy paste a sample program strait from the C for PIC Micro... I did all the steps describbed in the software and all I kept getting were errors when I tried to program my PIC using a 16f84a and a pic programer. Nothing as fancy as the matrix board or the PICstart plus.

 

   The next day I tried the following and it worked.

1.I wrote the program in c2c and saved it as whatevername.c . I actually added the .c extention although I don't think this should matter much.

2. I click on the C botton to compile from C language to assembler. I did not press anything else nor change any of the other options.

3. I open the latest version of MPASM free from microchip website.

4. I opened the whatervername.ASM file. I made sure that the pic16f84a was selected ad then I press the assemble botton.

5. Once the thing was asemble into a .HEX file I open my PICprogramer utility. That is the software that I used to program the PIC that came with my PICprogramer.

6. I open the whatervername.HEX and hit the program botton. I did not verify for errors or anything. Just a simple program routine.

7. I put the PIC into my PIC tester which I build by myself. I made sure that the Master reset was not set low and the thing worked.

 

The short version is that just use c2c to change from C language to a .ASM and from then on use MPASm and then your PICstart plus programer routine. Hope this helps

Share this post


Link to post
Share on other sites
Guest Pavel
1.I wrote the program in c2c and saved it as whatevername.c . I actually added the .c extention although I don't think this should matter much.

2. I click on the C botton to compile from C language to assembler. I did not press anything else nor change any of the other options.

3. I open the latest version of MPASM free from microchip website.

4. I opened the whatervername.ASM file. I made sure that the pic16f84a was selected ad then I press the assemble botton.

5. Once the thing was asemble into a .HEX file I open my PICprogramer utility. That is the software that I used to program the PIC that came with my PICprogramer.

6. I open the whatervername.HEX and hit the program botton. I did not verify for errors or anything. Just a simple program routine.

7. I put the PIC into my PIC tester which I build by myself. I made sure that the Master reset was not set low and the thing worked.

 

The short version is that just use c2c to change from C language to a .ASM and from then on use MPASm and then your PICstart plus programer routine. Hope this helps

This is exactly the way how c2c compiler is supposed to work with real hardware but in addition the steps 3,4,5,6,7 can be done from PicAntIDE (one needs to specify command lines for assembler and programmer in the PicAntIDE Settings->Options->Tools dialog page).

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...