PDA

View Full Version : problem with MCS



James1
- 1st December 2010, 20:42
Hi -

I am trying to program PIC16F877A(16Mhz) bootloader. The language in which I have written the code is Basic, and the compiler is Microcode studio.
The program gets compiled correctly producing a hex file. Now when I download the hex fie in the controller the controller doesn't respond to the code.

The code is :

'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 11/23/2010 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************

@ device PIC16F877A,HS_OSC
@ device PIC16F877A,WDT_OFF
@ device PIC16F877A,PWRT_OFF
@ device PIC16F877A,DEBUG_OFF
@ device PIC16F877A,CPD_OFF
@ device PIC16F877A,PROTECT_OFF

loop: high 1
pause 20
low 1
pause 20
goto loop

end


Is this the problem with the configuration bits or it is something else(compiler). If you know some other Basic compiler, please send me the link so that I can
download it.

BobK
- 1st December 2010, 23:32
Hi James1,

Start by adding "DEFINE OSC 16"

You told the compiler you are using a high speed oscillator with the HS_OSC but you didn't tell it what speed.

Next make your pause statements at least 1000 initially. All you will see with pause 20 is a light or led that's always on.

This should get you going.

BobK

Archangel
- 2nd December 2010, 04:48
Hi James,
@ device PIC16F877A,HS_OSC

Speed costs something, nearly always, in this case it is energy, the config HS, XT . . . are essentially power settings for the oscillator, Bob correctly pointed you to the DEFINE OSC 16 which is supposed to always be in UPPERCASE as he has shown. What this does mostly, is allows PBP to set the timing of it's commands to the correct value so pause 1000 really is 1 second and so serial communications are sent at the programmed value.
BTW you must be using a version of PBP prior to the latest release of 2.60 as the word "loop" is now a RESERVED word, when you upgrade you will have to use some other method, something like MyLoop or MainLoop. Might be a good idea to start now so as to get out of the habit and make your programs compatible so when Later on you decide to reuse some old code it will compile without error. IMHO
HTH
JS