View previous topic :: View next topic |
Author |
Message |
analog_world
Joined: 16 Sep 2008 Posts: 26
|
Confused about Loading hex files from CCS |
Posted: Thu Sep 18, 2008 4:58 am |
|
|
Hi guys,
I am a novice at programming microcontrollers and just started using CCS compiler. I bought this PIC development board, QL200 from a Chinese company. The board works extremely fine and is supplied along with its own programmer software to burn the hex files. I used the example hex files supplied by the manufacturer to load onto the PIC and see the results on the onboard modules such as LED's, LCd, buzzer..etc. Then, I used the hex file generated by the CCS compiler for the short and simple programs I wrote (for example, turning on LEd's on a port..etc) in CCS. The problem is that I don't see anything happening on the on board modules even after I successfully burn the CCS output hex file on to the PIC. For example, the LED's on a given port just stay the same without change even after programming the PIC. I am concerned whether I am doing it the right way or do I need to use MPLAB in any way. Please help. I really appreciate it. Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 18, 2008 12:23 pm |
|
|
Here is the website for the board.
http://www.pic16.com/en/wzcapi/ql200.htm
The board appears to have a 16F877A with a 4 MHz crystal. It has
LEDs on Port B. Therefore, the following program should blink an LED
on pin B0. There are DIP switches that enable each of the LEDs.
Make sure that the DIP switch for the LED on Pin B0 is "on".
Code: |
#include <16F877A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
//===============================
void main()
{
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
|
analog_world
Joined: 16 Sep 2008 Posts: 26
|
|
Posted: Thu Sep 18, 2008 8:19 pm |
|
|
Hi, Thank you and the code works. I had a question though, how can you use the output_high function without first setting the corresponding PortB pins to be in output mode using the Set_tris function. Infact, initially i set my clock to be 8 MHz in the pic wizard which didn't work out for me. But when I just used the preset 20MHz in the picwizard it works. Can you explain why did this happen?? Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 18, 2008 8:35 pm |
|
|
Quote: |
In fact, initially i set my clock to be 8 MHz in the pic wizard which didn't
work out for me. But when I just used the preset 20MHz in the pic wizard
it works. |
The photograph of the board shows a 4 MHz crystal. You need to look
at your board, to what crystal it really has.
Quote: | how can you use the output_high function without first setting the
corresponding PortB pins to be in output mode using the Set_tris function |
The CCS compiler automatically sets the correct TRIS, provided that you
use the CCS i/o functions. This is the default mode of the compiler.
You don't have to specify it. This feature allows you to write code more
easily than with other compilers. |
|
|
|