View previous topic :: View next topic |
Author |
Message |
pickit
Joined: 30 Dec 2011 Posts: 2
|
A big problem with CCS |
Posted: Fri Dec 30, 2011 2:34 pm |
|
|
Hey guys!
I'm a new user with CCS compiler because currently i use MikroC pro for my program and development. So today i wrote a code in C but it take many places in the evaluate version of mikro that i have so i cannot compile it and generate hex file.
My question is that in my first program that i wrote on MikroC, it use this function to make a sound a certain frequency during a certain time.
Code: |
void Tonalité() {
Sound_Play(770, 100); //frequency 770 hz during 100 ms
}
|
and this function to initialize the port where the speaker will be connected,
Code: |
Sound_Init(&PORTB, 2); // port RB2 for example
|
So now! The migration to a new compiler is a big problem cause in fact i want to do exactly the same function using CCS compiler but i did not find in the library of CCS function that can make this purpose. So do you have an idea of how I can translate these two functions to adapt it from the new compiler CCS ?
Thanks you |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9240 Location: Greensville,Ontario
|
|
Posted: Fri Dec 30, 2011 3:01 pm |
|
|
Sound_Play( f,d) is a 'function' or subroutine that was written for the other compiler.
While CCS doesn't have the equivalent function, it is easy for you to make your own.
One way is to take the listing of the compiled code and create your own 'function' using the inline code capablility,then call it as required.
Another is to disassemble the code, convert to CCS C code and again, you've created the same function.
You could ask 'Google ' and see what comes up as you're not the first one who wants a function from one compiler to be used on another.
The same holds true for any 'function' or command that any language or compiler has.
All you have to do is invest in some time to get what you want. |
|
|
pickit
Joined: 30 Dec 2011 Posts: 2
|
|
Posted: Fri Dec 30, 2011 3:07 pm |
|
|
Hey thanks for you response.
I am interested by the second option which is to disassemble the function and to convert it to CCS compiler but i have no idea of how we can do that. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sat Dec 31, 2011 1:11 pm |
|
|
from looking at the user doc on MikroC - it is clear that "sound" is timer or loop based square wave output generator of pretty simplistic design.
in fact a fast run through the MikroC manual was almost as depressing as hitech _C - the uart functions are actually BIZARRE - in that they are not presented as standardized C at all. AND clumsy as can be.
i have to say that it makes me more certain than ever of my satisfaction and delight with CCS
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9240 Location: Greensville,Ontario
|
|
Posted: Sat Dec 31, 2011 2:20 pm |
|
|
Yup, been with CCS since Feb 1998 and have never looked back !
It's always been able to do what I want and more. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sat Dec 31, 2011 2:39 pm |
|
|
Anyone now which timer(s) they are using for the Sound_Play()
routine? To duplicate the functionality of the MikroC version we need
to know. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Dec 31, 2011 2:56 pm |
|
|
You can probably translate the sound functions to CCS if you can identify
the ASM code for it in the .LST file produced by MikroC.
In this thread, I explain how to find and translate the PicBasicPro
POT command to CCS, and then someone does it:
http://www.ccsinfo.com/forum/viewtopic.php?t=27191
In this thread I show the PicBasicPro ASM code for the COUNT command:
http://www.ccsinfo.com/forum/viewtopic.php?t=31876
And this thread contains a translation to CCS, though it's in CCS ASM,
not in C:
http://www.ccsinfo.com/forum/viewtopic.php?t=41877
But anyway, this should give you an idea of how to do it. First you should
make a small test program (in the non-CCS language) that uses the
desired function (the smaller the better) and compile it. Then study
the .LST file to find the ASM code for the Sound library functions.
Then translate that code to CCS C, or to CCS ASM. |
|
|
|