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

linking problem ?

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



Joined: 22 Aug 2007
Posts: 2

View user's profile Send private message

linking problem ?
PostPosted: Fri Sep 28, 2007 3:48 am     Reply with quote

Hi, I have a problem with my project. I did a test with a multiple compilation unit.

This is my code in keybox.c
Code:

#include <18F4620.h>
#include "serial.h"

#fuses H4

#byte TRISC   =      0xF94
#byte TRISB   =      0xF93
#byte PORTB   =      0xF81

void main()
{
   TRISB = 0x00;
   PORTB = 0x03;

   initComm();
   
   while (1)
   {
      putch('T');
   }
}


then serial.h
Code:

void initComm(void);
void putch(unsigned char param);

finally serial.c
Code:

#include <18F4620.h>

#define BAUD 115200     
#define FOSC 40000000L

#define DIVIDER ((int16)(FOSC/(16UL * BAUD) -1))
#define SPEED 0x4


#byte TRISC   =      0xF94
#define _TRISC         0xF94
#byte SPBRG   =      0xFAF
#byte TXSTA   =      0xFAC
#define _TXSTA         0xFAC
#bit  TRISC6   =   _TRISC.6
#bit  TRISC7   =   _TRISC.7
#byte TXREG   =      0xFAD
#define _TXREG         0xFAD
#bit  TRMT   =      _TXSTA.1

void initComm(void)
{
   SPBRG = DIVIDER;       
   TXSTA = (SPEED|0x20);
   TRISC6=0;
   TRISC7=1;
}

void putch(unsigned char param)
{
   while(!TRMT);
   TXREG = param;
}


And now the result in disassembly lisnting:
Code:

---  C:\Documents and Settings\fjullien\Mes documents\Electronique\µC\ProtectsPIC\keybox\keybox.c
1:                 #include <18F4620.h>
  0000    EF10     GOTO 0x20
2:                 #include "serial.h"
3:                 
4:                 #fuses H4
5:                 
6:                 #byte TRISC   =      0xF94
7:                 #byte TRISB   =      0xF93
8:                 #byte PORTB   =      0xF81
9:                 
10:                void main()
11:                {
  0020    6AF8     CLRF 0xff8, ACCESS
  0022    9ED0     BCF 0xfd0, 0x7, ACCESS
  0024    6AEA     CLRF 0xfea, ACCESS
  0026    6AE9     CLRF 0xfe9, ACCESS
  0028    50C1     MOVF 0xfc1, W, ACCESS
  002A    0BC0     ANDLW 0xc0
  002C    090F     IORLW 0xf
  002E    6EC1     MOVWF 0xfc1, ACCESS
  0030    0E07     MOVLW 0x7
  0032    6EB4     MOVWF 0xfb4, ACCESS
12:                   TRISB = 0x00;
  0034    6A93     CLRF 0xf93, ACCESS
13:                   PORTB = 0x03;
  0036    0E03     MOVLW 0x3
  0038    6E81     MOVWF 0xf81, ACCESS
14:               
15:                   initComm();
  003A    D7E4     BRA 0x4
16:                   
17:                   while (1)
18:                   {
19:                      putch('T');
  003C    0E54     MOVLW 0x54
  003E    6E06     MOVWF 0x6, ACCESS
  0040    D7E9     BRA 0x14
20:                   }
  0042    D7FC     BRA 0x3c
21:                }
  0004    0E14     MOVLW 0x14
  0006    6E5E     MOVWF 0x5e, ACCESS
  0008    0E24     MOVLW 0x24
  000A    6E58     MOVWF 0x58, ACCESS
  000C    9829     BCF 0x29, 0x4, ACCESS
  000E    8C29     BSF 0x29, 0x6, ACCESS
  0010    EF1E     GOTO 0x3c
  0014    A458     BTFSS 0x58, 0x2, ACCESS
  0016    D7FE     BRA 0x14
  0018    C006     MOVFF 0x6, 0xf5a
---  C:\Documents and Settings\fjullien\Mes documents\Electronique\µC\ProtectsPIC\keybox\keybox.hex
1:                 :020000040000FA
2:                 :1000000010EF00F0140E5E6E240E586E2998298CA5
3:                 :100010001EEF00F058A4FED706C05AFF21EF00F0F3
4:                 :10002000F86AD09EEA6AE96AC150C00B0F09C16E36
5:                 :10003000070EB46E936A030E816EE4D7540E066EFB
6:                 :06004000E9D7FCD7030024
7:                 :020000040030CA
8:                 :0E00000000061E1E008381000FC00FE00F409F
9:                 :00000001FF
10:                ;PIC18F4620
  001C    EF21     GOTO 0x42
---  C:\Program Files\PICC\devices\18F4620.h  ----------------------------------------------------
1:                 //////// Standard Header file for the PIC18F4620 device ////////////////
  0044    0003     SLEEP


That's a long post Smile In serial.c, all the memory reference (SPBRG, TXSTA,...) are wrong. Look the putch wait loop:
Code:

  0014    A458     BTFSS 0x58, 0x2, ACCESS
  0016    D7FE     BRA 0x14


0x58 ?!?

When I put everything in the same file, everything is ok....linking problem ?

I'm using ccs 4.052.

Thanks in adavance.

Franck
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

PostPosted: Fri Sep 28, 2007 4:10 am     Reply with quote

You didn't search the forum dont you ?

8-9 topics under you! hehe

Repeat: i will always STF before posting a topic Wink

more details here --> Click to forward...
crevars



Joined: 22 Aug 2007
Posts: 2

View user's profile Send private message

PostPosted: Fri Sep 28, 2007 5:30 am     Reply with quote

Yes I did but I think I'm following those rules....Everyhting is compiling ok but the code is wrong.
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