Help sharing variables between C and Assembly.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
    
     

I'm trying to update the software for a firmware chipset, and I'm having trouble understanding how variables are passed between C and assembly. When I try to compile, I get these errors:

     

https://gist.github.com/anonymous/d79f8f9734865a3ec1fe

     

These variables are defined in global.h here:

     

https://gist.github.com/anonymous/d81de7895838eaa41361

     

Also, lib/timer8_1int.asm is pretty short, so here it is:

     

https://gist.github.com/anonymous/848875129e7cf16e110f

     

Thank you for your time.

     

I'm using PSoC Designer 5.4 to write and compile this code, if that helps anyone.

    
   
0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You will have to declare the other missing variables for the timer to remove some more errors.

   

I would suggest you to change the library include part in your project, file main.c to

   

 

   

 *************************************************************************************
 *                     Copyright Triangle MicroSystems, Inc. 2003
 *************************************************************************************/
#include <m8c.h>
#include <PSoCAPI.h> // This is essential!!
#include <math.h>
#include <FlashBlock.h>
#include "prototype.h"
#include "global.h"
#include "const.h"
#include "table.h"


/**************** Start Boot Loader Code ****************/
 

   

 

   

Bob

View solution in original post

0 Likes
9 Replies
Anonymous
Not applicable

You defined the variables in global.h, but did you declare in another file?

   

 

   

We could help you more if you post the complete project.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Answer is quite the same: In Designer -> Help -> Documentation there are the manuals for the C-Compiler and the assembly. There you will find explanations about naming and linkace for C-interface to asm. Posting a complete project goes: Designer -> File -> Archive Project and attaching the resulting .zip file here.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Here is the complete project. In the meantime, I wil look through the documentation. Thanks again for the help.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

I just realized the project I posted has some changes I had been working on. Here is the original untouched set. The only difference between the two are the addition of

   

 

   

char    timer_heart_beat;
char    timer_damp_pos;
char    timer_sample_freg;

   

 

   

at the beginning of main.c to fix 3 of the errors.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You will have to declare the other missing variables for the timer to remove some more errors.

   

I would suggest you to change the library include part in your project, file main.c to

   

 

   

 *************************************************************************************
 *                     Copyright Triangle MicroSystems, Inc. 2003
 *************************************************************************************/
#include <m8c.h>
#include <PSoCAPI.h> // This is essential!!
#include <math.h>
#include <FlashBlock.h>
#include "prototype.h"
#include "global.h"
#include "const.h"
#include "table.h"


/**************** Start Boot Loader Code ****************/
 

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi, Bob thanks for the reply.

   

 

   

I have replaced the original included libraries to the set you posted, but that didn't seem to fix any errors yet. Right now I'm only having trouble getting timer_1msec, timer_10msec, and timer_100msec defined in the file Timer_1INT.asm, or so it would seem from the errors displayed.

   

 

   

 

   

!ERROR {linker} file 'timer8_1int.o': undefined symbol '_timer_1msec'
!ERROR {linker} file 'timer8_1int.o': undefined symbol '_timer_10msec'
!ERROR {linker} file 'timer8_1int.o': undefined symbol '_timer_100msec'

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I said in my last post: "You will have to declare the other missing variables for the timer to remove some more errors."

   

So, as you did with

   

char    timer_heart_beat;
char    timer_damp_pos;
char    timer_sample_freg;

   

 

   

I suggest you to initialize those vars with zero.

   

 

   

Bob

Anonymous
Not applicable

Bob,

   

 

   

Thank you for your patience. I am very new to writing code and many references still fly over my head.

   

 

   

Declaring the variables with "char" at the beginning of main.c made everything compile! Thank you for your help. I am still foggy, though, on how to initialize these variables with a 0. I am not sure if that is still necessary at this point, but any more tips would be greatly appreciated.

   

 

   

Thank you again for taking a look.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Just use a syntax like

   

char    timer_heart_beat = 0; // timer_heart_beat to zero

   

 

   

Bob