Forums

Read/Write to GPIO!

Started by Ali October 11, 2006
Hey eeryOne,

My complier reports it as "Not an lvalue";-)And i'm trying todo
somthing like :

X:GPIO_B_DDR = ( 1 << var ) ;

X:GPIO_B_DDR = (1 << | 1 << var2 ) ;

Any idea how to fix it for CW ?

I can compile following line but can't load the variable value.
asm(move #1, X:GPIO_B_DDR); // It is OK

int some =34;

asm(move #@ABS(some), X:GPIO_B_DDR); // an ERROR here

And how about LEA? damn its first time to work with DSP , CW and
Motorola gadgets.I've got the MOTOROLA DSP ASM REF Manual but can't
find any C manual, any clue for that?

Thanks for your time
ali

Ali wrote:
> Hey eeryOne, > > My complier reports it as "Not an lvalue";-)And i'm trying todo > somthing like : > > X:GPIO_B_DDR = ( 1 << var ) ; > > X:GPIO_B_DDR = (1 << | 1 << var2 ) ; > > Any idea how to fix it for CW ? >
<snip> I am not familiar enough with your system's architecture to tell you specifically how to perform the operation you are attempting to perform , but in the message "Not an lvalue", the term lvalue is a reference to the "Left side of the equal sign", the item that the expression on the right side is being assigned to. In other words, the error message is indicating that you are attempting to assign a value to an item that can not receive assignments.
Noway2 wrote:
> Ali wrote: > > Hey eeryOne, > > > > My complier reports it as "Not an lvalue";-)And i'm trying todo > > somthing like : > > > > X:GPIO_B_DDR = ( 1 << var ) ; > > > > X:GPIO_B_DDR = (1 << | 1 << var2 ) ; > > > > Any idea how to fix it for CW ? > > > <snip> > > I am not familiar enough with your system's architecture to tell you > specifically how to perform the operation you are attempting to perform > , but in the message "Not an lvalue", the term lvalue is a reference to > the "Left side of the equal sign", the item that the expression on the > right side is being assigned to. In other words, the error message is > indicating that you are attempting to assign a value to an item that > can not receive assignments.
Thanks for valuable comments. Yeah you are absolutely right here and i do understand your point. Sorry for not mentioning the architecture i though that it would unnecessary to write, any way i'm using DSP56F801 (freescale) chip with CodeWorrior compiler. Frankly i'm not new to programming, do have MCU , system programming knowledge and device drivers a bit but at the same time i'm somehow new to DSP world and the worst thing is new to this specific tool set. let me elaborate my problem again. AFAIK according to data sheet port B's DDR is 8 bit r/w register so putting it at left hand does make sense to me. X:GPIO_B_DDR is 8 bit register so IMHO why i can't use it as a left operand? i guess something wrong with syntax and damn one of my work fellow has miss placed the evaluation kit CDs so don't have much resources to dig in;-) i'll get another kit in next few days or weeks and i don't want to wait that long. Thanks again for followup. ali
Ali wrote:
> Noway2 wrote: > > Ali wrote: > > > Hey eeryOne, > > > > > > My complier reports it as "Not an lvalue";-)And i'm trying todo > > > somthing like : > > > > > > X:GPIO_B_DDR = ( 1 << var ) ; > > > > > > X:GPIO_B_DDR = (1 << | 1 << var2 ) ; > > > > > > Any idea how to fix it for CW ? > > > > > <snip> > > > > I am not familiar enough with your system's architecture to tell you > > specifically how to perform the operation you are attempting to perform > > , but in the message "Not an lvalue", the term lvalue is a reference to > > the "Left side of the equal sign", the item that the expression on the > > right side is being assigned to. In other words, the error message is > > indicating that you are attempting to assign a value to an item that > > can not receive assignments. > > > Thanks for valuable comments. > > Yeah you are absolutely right here and i do understand your point. > Sorry for not mentioning the architecture i though that it would > unnecessary to write, any way i'm using DSP56F801 (freescale) chip > with CodeWorrior compiler. > Frankly i'm not new to programming, do have MCU , system programming > knowledge and device drivers a bit but at the same time i'm somehow new > to DSP world and the worst thing is new to this specific tool set. > > let me elaborate my problem again. AFAIK according to data sheet port > B's DDR is 8 bit r/w register so putting it at left hand does make > sense to me. > X:GPIO_B_DDR is 8 bit register so IMHO why i can't use it as a left > operand? i guess something wrong with syntax and damn one of my work > fellow has miss placed the evaluation kit CDs so don't have much > resources to dig in;-) i'll get another kit in next few days or weeks > and i don't want to wait that long. > > > > Thanks again for followup. > ali
This is just a guess, but I would say that the assignment operation is attempting to perform a memory operation. If the IO ports use IN and OUT operations with dedicated opcodes for those operations, they may not work with this type of assignment. While it is pretty obvious to the human what you are intending to do, the compiler may not support this and hence the error message. I would suggest checking to see if you can find either an instruction set manual or an assembly language reference guide. Either one of these manuals should tell you if the processor has dedicated IO instructions, which many do. The last Freescale chips I used were the HC12 and HC16, back in the days when they were still Motorola and it has been so long that I can't really remember the instruction sets.
Noway2 wrote:
> Ali wrote: > > Noway2 wrote: > > > Ali wrote: > > > > Hey eeryOne, > > > > > > > > My complier reports it as "Not an lvalue";-)And i'm trying todo > > > > somthing like : > > > > > > > > X:GPIO_B_DDR = ( 1 << var ) ; > > > > > > > > X:GPIO_B_DDR = (1 << | 1 << var2 ) ; > > > > > > > > Any idea how to fix it for CW ? > > > > > > > <snip> > > > > > > I am not familiar enough with your system's architecture to tell you > > > specifically how to perform the operation you are attempting to perform > > > , but in the message "Not an lvalue", the term lvalue is a reference to > > > the "Left side of the equal sign", the item that the expression on the > > > right side is being assigned to. In other words, the error message is > > > indicating that you are attempting to assign a value to an item that > > > can not receive assignments. > > > > > > Thanks for valuable comments. > > > > Yeah you are absolutely right here and i do understand your point. > > Sorry for not mentioning the architecture i though that it would > > unnecessary to write, any way i'm using DSP56F801 (freescale) chip > > with CodeWorrior compiler. > > Frankly i'm not new to programming, do have MCU , system programming > > knowledge and device drivers a bit but at the same time i'm somehow new > > to DSP world and the worst thing is new to this specific tool set. > > > > let me elaborate my problem again. AFAIK according to data sheet port > > B's DDR is 8 bit r/w register so putting it at left hand does make > > sense to me. > > X:GPIO_B_DDR is 8 bit register so IMHO why i can't use it as a left > > operand? i guess something wrong with syntax and damn one of my work > > fellow has miss placed the evaluation kit CDs so don't have much > > resources to dig in;-) i'll get another kit in next few days or weeks > > and i don't want to wait that long. > > > > > > > > Thanks again for followup. > > ali > > This is just a guess, but I would say that the assignment operation is > attempting to perform a memory operation. If the IO ports use IN and > OUT operations with dedicated opcodes for those operations, they may > not work with this type of assignment. While it is pretty obvious to > the human what you are intending to do, the compiler may not support > this and hence the error message. > > I would suggest checking to see if you can find either an instruction > set manual or an assembly language reference guide. Either one of > these manuals should tell you if the processor has dedicated IO > instructions, which many do. > > The last Freescale chips I used were the HC12 and HC16, back in the > days when they were still Motorola and it has been so long that I can't > really remember the instruction sets.
Thanks for followup, yeah i've already fixed the problem with the help of PE which is indeed quite handy. Yeah it is damn easy thing to do. Anyway now i want to decode incoming signal (i.e. frequency_counter). I did try to use 'capture' or 'ExtInt' beans but no luck guess something still missing. Any thoughts for that? For the sake of reference , i'm can do following for GPIO read write without PE: 0) Enable the peripheral in PER register while setting those bits to high 1) Enabling the DDR for output (1;high for output , 0;for input). 2) And DR is ready to cook. /////////////////////////////// register po; asm(move #$0002 , X:GPIO_B_DR); po = 0; while(1) { /* 1) */ asm(move X:GPIO_B_DR , X0); /* 2) */ asm(move X0 , po); po = po + 2; /* 3) */asm(move po , X0); /* 4) */asm(move X0 , X:GPIO_B_DR ); } ////////////////////// ali
Ali wrote:

> Thanks for followup, yeah i've already fixed the problem with > the help of PE which is indeed quite handy. > Yeah it is damn easy thing to do. Anyway now i want to decode incoming > signal (i.e. frequency_counter). I did try to use 'capture' or > 'ExtInt' beans but no luck guess something still missing. Any thoughts > for that?
No I am afraid that I don't. I have never used that option. I am planning on attempting something similar on a different processor family but that wouldn't help you. I would suggest seeing if someone else resonds to this thread and if not, try posting again on that subject giving as much detail as possible about what you are tyring to do, how you are trying to do it, and what kinds of problems you are running into.
Noway2 wrote:
> Ali wrote: > > > Thanks for followup, yeah i've already fixed the problem with > > the help of PE which is indeed quite handy. > > Yeah it is damn easy thing to do. Anyway now i want to decode incoming > > signal (i.e. frequency_counter). I did try to use 'capture' or > > 'ExtInt' beans but no luck guess something still missing. Any thoughts > > for that? > > No I am afraid that I don't. I have never used that option. I am > planning on attempting something similar on a different processor > family but that wouldn't help you. > > I would suggest seeing if someone else resonds to this thread and if > not, try posting again on that subject giving as much detail as > possible about what you are tyring to do, how you are trying to do it, > and what kinds of problems you are running into.
Sure! i'll. Once i'm as well sure about our reqirements. Actually it is an analog device and incoming signal is coming via baseband so no AD Converstion is required at the moment.Yes for exploring the true magics of DSP core we will eventually drop the baseband from our design to count in the filters;-) I have heard a lot about dsp parallel processing which means that AFAIK i can actually have to ISR executing at the same time ,right? or say that i can decode tow input signals at any given time! correct me if i'm thinking wrong here ;) ali