Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 23, 2024, 01:00:19 13:00


Login with username, password and session length


Pages: [1]
Print
Author Topic: Ccs Help  (Read 7761 times)
0 Members and 2 Guests are viewing this topic.
lsis
Newbie
*
Offline Offline

Posts: 12

Thank You
-Given: 0
-Receive: 1


« on: January 15, 2006, 11:08:09 23:08 »

Any idea for assign (pin_c0, pin_b2 , pin_d3 .....) with int16 variable.
Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #1 on: January 17, 2006, 06:54:46 18:54 »

Hi

The guy needs to do the following;

He creats a 16 bit variable:

int16 var;

Now he wants to assign PIN_A0 for example to one of the var bits, say:

PIN_A0 = var.3; or vice versa.

So that PIN_A0 will change when the 3rd bit in var is changed, or viceversa.

How can he do such a thing ?

Thanks to all
« Last Edit: January 17, 2006, 06:58:11 18:58 by metal » Logged
lsis
Newbie
*
Offline Offline

Posts: 12

Thank You
-Given: 0
-Receive: 1


« Reply #2 on: January 17, 2006, 11:24:22 23:24 »

Thank's METAL.

Now the solution.

// ISD25120 TO PIC18F452 ADDRESS PINS. //
#BIT ISDADRS0 = 0XF82.0
#BIT ISDADRS1 = 0XF84.2
#BIT ISDADRS2 = 0XF84.1
#BIT ISDADRS3 = 0XF84.0
#BIT ISDADRS4 = 0XF80.5
#BIT ISDADRS5 = 0XF80.4
#BIT ISDADRS6 = 0XF80.3
#BIT ISDADRS7 = 0XF80.2
#BIT ISDADRS8 = 0XF80.1
#BIT ISDADRS9 = 0XF80.0
// ISD25120 DIRECT ADDRESS MACRO FUNCTION. //
#define ISDADRS(x) \
ISDADRS0 = x & 1; \
ISDADRS1 = (x >> 1) & 1; \
ISDADRS2 = (x >> 2) & 1; \
ISDADRS3 = (x >> 3) & 1; \
ISDADRS4 = (x >> 4) & 1; \
ISDADRS5 = (x >> 5) & 1; \
ISDADRS6 = (x >> 6) & 1; \
ISDADRS7 = (x >> 7) & 1; \
ISDADRS8 = (x >> Cool & 1; \
ISDADRS9 = (x >> 9) & 1

With this macro we have only to change x at ISDADRS(x).
Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #3 on: January 17, 2006, 11:35:35 23:35 »

Hi isis

Can you explain more plz, I don't understand any thing now  :confused:
Logged
lsis
Newbie
*
Offline Offline

Posts: 12

Thank You
-Given: 0
-Receive: 1


« Reply #4 on: January 18, 2006, 12:08:12 00:08 »

What is so dificult ?

// ISD25120 TO PIC18F452 ADDRESS PINS. //
#BIT ISDADRS0 = 0XF82.0                                  // here is the address of pin_c0
#BIT ISDADRS1 = 0XF84.2                                  // here is the address of pin_e3
#BIT ISDADRS2 = 0XF84.1
#BIT ISDADRS3 = 0XF84.0
#BIT ISDADRS4 = 0XF80.5
#BIT ISDADRS5 = 0XF80.4
#BIT ISDADRS6 = 0XF80.3
#BIT ISDADRS7 = 0XF80.2
#BIT ISDADRS8 = 0XF80.1
#BIT ISDADRS9 = 0XF80.0
// ISD25120 DIRECT ADDRESS MACRO FUNCTION. //
#define ISDADRS(x) \
ISDADRS0 = x & 1; \
ISDADRS1 = (x >> 1) & 1; \
ISDADRS2 = (x >> 2) & 1; \
ISDADRS3 = (x >> 3) & 1; \
ISDADRS4 = (x >> 4) & 1; \
ISDADRS5 = (x >> 5) & 1; \
ISDADRS6 = (x >> 6) & 1; \
ISDADRS7 = (x >> 7) & 1; \
ISDADRS8 = (x >> Cool & 1; \
ISDADRS9 = (x >> 9) & 1
Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #5 on: January 18, 2006, 12:23:08 00:23 »

Hi isis

I understand this part and know it already:

// ISD25120 TO PIC18F452 ADDRESS PINS. //
#BIT ISDADRS0 = 0XF82.0 // here is the address of pin_c0
#BIT ISDADRS1 = 0XF84.2 // here is the address of pin_e3
#BIT ISDADRS2 = 0XF84.1
#BIT ISDADRS3 = 0XF84.0
#BIT ISDADRS4 = 0XF80.5
#BIT ISDADRS5 = 0XF80.4
#BIT ISDADRS6 = 0XF80.3
#BIT ISDADRS7 = 0XF80.2
#BIT ISDADRS8 = 0XF80.1
#BIT ISDADRS9 = 0XF80.0

But how to use this in order to assign a pin to a bit in a variable, thats what I meant:

// ISD25120 DIRECT ADDRESS MACRO FUNCTION. //
#define ISDADRS(x) \
ISDADRS0 = x & 1; \
ISDADRS1 = (x >> 1) & 1; \
ISDADRS2 = (x >> 2) & 1; \
ISDADRS3 = (x >> 3) & 1; \
ISDADRS4 = (x >> 4) & 1; \
ISDADRS5 = (x >> 5) & 1; \
ISDADRS6 = (x >> 6) & 1; \
ISDADRS7 = (x >> 7) & 1; \
ISDADRS8 = (x >> Cool & 1; \
ISDADRS9 = (x >> 9) & 1
« Last Edit: January 18, 2006, 12:49:29 00:49 by metal » Logged
lsis
Newbie
*
Offline Offline

Posts: 12

Thank You
-Given: 0
-Receive: 1


« Reply #6 on: January 18, 2006, 12:27:49 00:27 »

We can't do that.
For this reason we make the macro and now the x is variable.

void main()
{

int16 x = 0;

SET_TRIS_A(0B11000000);
SET_TRIS_B(0B11111111);
SET_TRIS_C(0B10101110);
SET_TRIS_D(0B11100111);
SET_TRIS_E(0B11111000);

   DO {
   ISDADRS(x);
   x=x+1;
   delay_ms(10);
      }
      WHILE (x<1024);
 
}

I don't know how can we do that you are ask for now.
I am new in ccs.
« Last Edit: January 18, 2006, 01:01:13 01:01 by lsis » Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #7 on: January 18, 2006, 01:07:33 01:07 »

Hi isis

me too  Cheesy

thanx
Logged
Faros
Senior Member
****
Offline Offline

Posts: 254

Thank You
-Given: 141
-Receive: 178


« Reply #8 on: January 18, 2006, 05:22:09 17:22 »

Hi metal



Those posts were just superb  â€¦:D Cheesy Cheesy  .....   well play man ....  Cheesy Cheesy Cheesy Cheesy
Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #9 on: January 19, 2006, 05:54:23 05:54 »

Faros,

Really, aint a play, I am new to CCS, I see that these things are easily done with basic language VAR.3 = PORTA.0 , I don't know why C tries to complicate such things !! What do you think faros...
Logged
Faros
Senior Member
****
Offline Offline

Posts: 254

Thank You
-Given: 141
-Receive: 178


« Reply #10 on: January 19, 2006, 07:33:28 07:33 »

I believe you are write… the time/benefit ratio writing codes in C is very high … to high for the number of boards to be produced for limited projects …. I guess it has been used by people who were already familiar with C before switching to microcontroller code writing … I can write in assembly but it dose not bay off for the time wasted in debugging and optimizing …. I use your version of proton+ … it is by far undersized in generated codes than Mikrobasic … more featured …and more stable   …. By the way thank you for Mikrobasic crack … only now it works fine for sources over the 2 pages
Logged
pama
Junior Member
**
Offline Offline

Posts: 74

Thank You
-Given: 10
-Receive: 28


« Reply #11 on: January 19, 2006, 09:59:16 09:59 »

Hi,
 
thanks for your good work, I started to learn CCS and after several month spend on assembly, it's more easily to write code in CCS. CCS has a very-very good forum on their web pages (not just in CCs quetions), with helpfull members. But  i don't know anything about microbasic.
have a good day
pama
Logged
Faros
Senior Member
****
Offline Offline

Posts: 254

Thank You
-Given: 141
-Receive: 178


« Reply #12 on: January 19, 2006, 04:56:22 16:56 »

Hi  pama …

Nothing wrong about using C … if you can write in C the fastest, then it is better than any basic .

as a rule ....…" The best code writing tool is the one that you master the most " …anyhow  in IT world C is much better than basic for many rezones … one of them is that it has optimized generated codes …  you C what i mean? Smiley
« Last Edit: January 19, 2006, 05:00:16 17:00 by Faros » Logged
pama
Junior Member
**
Offline Offline

Posts: 74

Thank You
-Given: 10
-Receive: 28


« Reply #13 on: January 19, 2006, 06:10:30 18:10 »

Hi Faros,
 
yes, i agree with you.That was the reason why i started pic-ing with C. But to be able to run a code, also have to be done the hardware, which is a little difficult for me Sad
pama
Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #14 on: January 19, 2006, 07:35:27 19:35 »

Hi

I think its the mistake of basic compiler writers in deed, I can see that people who wrote PICBasic Pro used C, but most compilers in basic didn't pay attention to code optimizing issues, I see that proton did, but its still young and needs alot of work to do with it.

Another thing I noticed is that coding in C looks more neaty and tidy than basic for PIC, but as long as I mastered basic for PIC in most basic compilers, I can say that its easier for me. I also managed to make my basic codes more neaty than those found in C.

The past experience in C for an engineer is not that big important, I did a lot of C in deed, when looking to PICs C, one has to read and read, as did with C for microsoft, as the two of them may have the same syntax, but they are for different platforms. what makes C more neat is the use of organised functions, I can say that mikrobasic did right when implemented procedures and functions.

last word to say is this, the best compiler is that the one you most master, there is no specific compiler that serves all projects on mind, so we better know what each project needs, and decide what compiler to use which best suites our project needs.

C U
Logged
lsis
Newbie
*
Offline Offline

Posts: 12

Thank You
-Given: 0
-Receive: 1


« Reply #15 on: January 19, 2006, 11:50:09 23:50 »

Hi FAROS.
Before talk so easy for everything simply think that exists also other side in the same currency.

L.S.
Logged
picstudent
Active Member
***
Offline Offline

Posts: 169

Thank You
-Given: 0
-Receive: 3


« Reply #16 on: January 20, 2006, 12:57:05 00:57 »

humm i think i 'll try CSS ....
Logged

... rego ... who are are you really ?
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC