CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Understanding .lst file

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pic_girl



Joined: 13 Apr 2005
Posts: 1

View user's profile Send private message

Understanding .lst file
PostPosted: Wed Apr 13, 2005 2:54 pm     Reply with quote

Hi. I am new to using the CCC PCM Compiler. I have been programming Microchip's midrange microcontrollers for the past two years using the RISC assembly language. I have just switched to programming in C using the CCS compiler with MPLAB IDE. Having done the assembly and switching over to C, it has been difficult for me because I am trying to fully understand the .LST file. I would like to know how the compiler pulls together data from the Microcontroller's register file map in their data sheet, to CCS's header file, and finally how it is compiled into assembly .LST file that I see. For example, I have been programming the PIC16F88 and, as a simple example, I want to set RA1 high. In my C code I have:
output_bit(PIN_A1,1);
The datasheet for the Pic16f88 says PortA is in bank 0 at file register 05h.

CCS's 16f88.h header file defines the individual porta pins, with RA1 being:
#define PIN_A1 41

In the .LST file, where I have used the command
output_bit(PIN_A1,1);
it shows :
BSF 05.1

I can see that the datasheet defines PORTA at address 05h and bsf 05.1 would set RA1 high, if I am understanding that correctly. However, how does this correspond to the header file and where could I find more information on mapping the C code, with the .LST file, with the header file, and the datatsheet for the microcontroller? Any help understanding this would be great! Confused
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 13, 2005 3:09 pm     Reply with quote

Quote:
#define PIN_A1 41
How does this correspond to the header file.

Convert the 41 decimal to hex, which gives 0x29.
Now convert that to binary, which is 00101001.
Break that up into bitfields, as follows: 00 101 001

Now convert the two lower bitfields to decimal: 5 1

That's where the Port 5, bit 1, comes from.
Ttelmah
Guest







PostPosted: Wed Apr 13, 2005 3:19 pm     Reply with quote

Realistically, you are trying to look beyond anything you should need to know. If you want to access a bit on different register, then just use #bit, or #byte to define it, and access it yourself, without using the standard functions. Touching the processor header file is only necessary if CCS get it wrong, otherwise it is better to leave this alone, and add your own definitions, since changing the file makes the code 'non standard', and effectively uncompilable for other people using the compiler (unless they too have your modifications). The list file is complete in it's own right (turn off the 'nolist' option to give the full printout). The 'output_bit' function (and the output_high, and output_low versions), are just macros designed to _hide_ the real accesses to the port from you. The format for the data, is simply the port address*8, plus the bit address, but they are not warranted to work for any addresses other than those included in the header, so it should never be necessary/sensible to generate these numbers. Remember also, that the output of the functions will change if you have 'standard_io' enabled, instead of 'fast_io', since then the compiler will automatically control the TRIS register as well as the IO register itself.
The actual data determining what features are supported for a processor, are in the file 'devices.dat'. Some can be edited with the device editor. Changing the header file on it's own, will just result in code that is unlikely to work...

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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