 |
 |
| View previous topic :: View next topic |
| Author |
Message |
jds-pic
Joined: 17 Sep 2003 Posts: 205
|
|
Posted: Tue Aug 16, 2005 3:49 pm |
|
|
i use the windows IDE. one feature i *really* like is looking at the .lst file, which shows the c source next to the compiled opcodes. perhaps the command line compiler used with an external editor (like Context) can do this, i don't know. but i think it's a useful feature.
example:
| Code: |
.................... display_message(MSG_HOSTCONTROL,MOD_NONE,TIMEOUT_NONE);
4914: MOVLW 08
4916: MOVWF xD9
4918: CLRF xDA
491A: CLRF xDB
491C: CALL 19F6
....................
.................... while (serial_port_byte_avail()) // clear serial buffer
.................... getch();
4920: BTFSS F9E.5
4922: BRA 492A
4924: CALL 1D84
4928: BRA 4920
....................
.................... while (command != HOST_CMD_QUIT_HOST_MODE) {
492A: MOVF xD3,W
492C: SUBLW 71
492E: BTFSC FD8.2
4930: BRA 4F18
.................... pushbutton_flag=FALSE;
4932: CLRF x9E
.................... delay_counter=(int16)TIMEOUT_HOSTMODE * (int16)100;
4934: MOVLW 0B
4936: MOVWF xD6
4938: MOVLW B8
493A: MOVWF xD5
....................
.................... while((!pushbutton_flag) && (!serial_port_byte_avail())) {
493C: MOVF x9E,F
493E: BNZ 4960
4940: BTFSC F9E.5
4942: BRA 4960
<...snip?
|
|
|
 |
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Tue Aug 16, 2005 4:13 pm |
|
|
| SBS wrote: | Ok... I couple more questions..
I downloaded the MPLAB IDE to fool around with. I was unable to find anywhere in it a C style editor. |
PCMProgrammer's previous post shows you how the C editor looks in there.
| Quote: |
I understand that MPLAB can emulate assembly code and let you step through it. I also understand that the PCH compiler from CCS is a command line comiler. Can you write C style code in MPLAB and then target the PCH compiler? Then step through the compiled assembly code?
|
Yup, you can step thru the C code, and also step thru the assembly. In fact, the corresponding C code is displayed alongside the assembly.
| Quote: |
Or do I need a separate third party C code editor program... compile the c file at the command prompt and then bring the assembly into MPLAB?
|
The MPLAB IDE can link in the compiler, and all your compiling will then be Windows-driven. No need to use a command line, but it is optional.
| Quote: |
When in the MPLAB emulation, is there any what that I can step through the C code? Or will my breakpoints be stopping in the assembly?
|
You can set breakpoints in the C code. The breakpoints will stop in the C line of code if you don't have a disassembly listing displayed.
| Quote: |
On a side note... I don't really understand why anyone would buy the CCS PCWH Windows IDE... Couldn't the exact same functionality be acquired by using a free download C aware editor and the command line compiler? I know that the PCWH has a built in debugger for use with the ICD-U40. Would that debug C code? I mean that would it be stepping through the C code or would I just see the breakpoints in the assembly?
|
The PCWx version has "optimization" flags you can set, while PCH has a non-changeable default optimization flag. I don't know how well this optimization flag really works though.
You don't need to download a C aware editor, since MPLAB provides a C-programming environment which highlights your C keywords and stuff. |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 16, 2005 4:52 pm |
|
|
Actually, the current version of PCH (vs. 3.231) does allow changing the
optimization level.
In the test program below, here are the results from the .LST file
with various levels of optimization:
| Code: |
#opt 11 ROM used: 332 bytes (1%) (opt 11 actually gets worse)
#opt 10 ROM used: 312 bytes (1%)
#opt 9 ROM used: 312 bytes (1%) (Default level)
#opt 8 ROM used: 364 bytes (1%)
#opt 7 ROM used: 372 bytes (1%)
#opt 6 ROM used: 384 bytes (1%)
#opt 5 ROM used: 384 bytes (1%) |
| Code: |
#opt 7
#include <18F452.h>
#fuses XT, NOWDT, NOPROTECT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#include <lcd.c>
void main()
{
lcd_putc(0x55);
while(1);
} |
|
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|