|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
AW: Re: Digest from coldfire@wildrice.comHi Bob
Just a side note. I work with several compilers and the CW warnings are in fact quite extreme and I do in fact keep them off since otherwise the casting required also becomes rather extreme. My solution is to compile the project with GCC and Visual-Studio C-compilers and ensure that they don't give any warnings - assuming that this is the case, then I am satisfied. Regards Mark -----Ursprüngliche Nachricht----- Von: coldfire-bounce@... [mailto:coldfire-bounce@...] Im Auftrag von Robert Ritchey Gesendet: Sonntag, 14. September 2008 16:44 An: mark@... Betreff: [ColdFire] Re: Digest from coldfire@... Hi Mark, Thank you very much for the detailed explanation. Its very clear now. I think with this help I can make some informed decisions on how to declare variable types. At 12:00 AM 9/14/2008 -0500, you wrote: >From: "Mark Butcher" <Mark@...> >To: <coldfire@...> >Subject: AW: [ColdFire] CodeWarrior Question >Date: Sat, 13 Sep 2008 21:21:47 +0200 >Message-ID: <000001c915d5$f7851080$e68f3180$@com> >Content-Type: text/plain; > charset="iso-8859-1" >Sender: coldfire-bounce@... >Reply-To: coldfire@... > >Hi Bob > >You can disable such warning by deactivating "implicit arithmetic >conversions" in "Language Settings+ -> "C/C++ warnings". > >... >Regards >Mark >www.uTasker.com > >-----Ursprüngliche Nachricht----- >Auftrag von Robert Ritchey >Gesendet: Samstag, 13. September 2008 17:29 >An: mark@... >Betreff: [ColdFire] CodeWarrior Question > >Hi, >I am new to CodeWarrior and pretty green in C so I hope this is not >a totally naive question. I have some code that takes two shorts and >... Thanks, > >typedef struct > { > short RiseEdge; /* Pulse rising >edge time */ > short FallEdge; /* Pulse >falling edge time */ > } ChanInStruct; > >bool TxPulseOffset(short *Offset) >{ > short PulseWidth; > /* Pulse width */ > PulseWidth = (short)(pRxChannelInput->FallEdge - >pRxChannelInput->RiseEdge); /* Pulse width is falling minus rising >} >At 12:04 AM 9/13/2008 -0500, you wrote: >-------------------------------------------------------------------- >Robert Ritchey >Quest Engineering & Development, Inc. -Bob -------------------------------------------------------------------- Robert Ritchey Quest Engineering & Development, Inc. Suite B/8 6125 South Ash Avenue Tempe, AZ 85283 Tel: (480) 460-2652 FAX: (480) 460-2653 E-Mail: RRRitchey@... E-Mail: RRRitchey@... E-Mail: RRRitchey@... E-Mail: RRRitchey@... WWW: www.QuestEngDev.com/ WWW: www.Smart-Fly.com/ -------------------------------------------------------------------- --- coldfire@... Send a post to the list. coldfire-join@... Join the list. coldfire-digest@... Join the list in digest mode. coldfire-leave@... Leave the list. --- coldfire@... Send a post to the list. coldfire-join@... Join the list. coldfire-digest@... Join the list in digest mode. coldfire-leave@... Leave the list. |
|
|
Re: AW: Re: Digest from coldfire@wildrice.com"Mark Butcher" wrote:
>Just a side note. I work with several compilers and the CW warnings are in >fact quite extreme and I do in fact keep them off since otherwise the >casting required also becomes rather extreme. >My solution is to compile the project with GCC and Visual-Studio C-compilers >and ensure that they don't give any warnings - assuming that this is the >case, then I am satisfied. well, a compiler is a compiler and no static code checker. I suggest to spend some bucks on PC-Lint - that's the _right_ tool. Lint early, lint often - Lint is your friend. Oliver --- coldfire@... Send a post to the list. coldfire-join@... Join the list. coldfire-digest@... Join the list in digest mode. coldfire-leave@... Leave the list. |
|
|
|
|
|
AW: Re: Digest from coldfire@wildrice.comHi Bob
It is normal that arithmetic operations will extend (or sign extend) but this should not cause any problems. Sign extending from signed to unsigned or unsigned to signed can of course cause errors but as long as the compile know the types (which it does . i.e. that you define these as you need them) there shouldn't be any problems. It is correct to zero extend an unsigned short to unsigned long. When extending a signed short to signed long it will depend on the first bit - if it is zero it will zero extend. If it is 1 it will one extend (to keep it negative). I don't understand the problem at the moment and I think that in your case you should really work with unsigned values (the pulse samples are always positive values). If you are getting a sign extension to a negative number this is very unexpected and points to an intermediate variable with un-matching type. I have used CW for a couple of years in a number of projects and never had any difficulties of this nature. Perhaps it would be useful to show the C and assembler in this specific case. You can right click the file in the CW explorer and right mouse click to get the context menu and the disassemble command. Then there will be C and assembler mixed, which could throw light on the matter. Regards Mark -----Ursprüngliche Nachricht----- Von: coldfire-bounce@... [mailto:coldfire-bounce@...] Im Auftrag von Robert Ritchey Gesendet: Montag, 15. September 2008 16:33 An: mark@... Betreff: [ColdFire] Re: Digest from coldfire@... Hi Mark, Thanks for that too. I am afraid I am mostly a hardware guy so this is about the only C compiler I have right now. In the past I did most of my work in assembly on the MSP430. Which brings me to one last question if I could impose. Basically what I am doing here is capturing a pulse by a time to determine the pulse width. I capture the rising and falling edges on a counter that is modulo 16 bits. The MSP430 is a 16-bit machine so to get the pulse width I just subtracted the falling edge from the rising edge value and got a positive value. The reason I went to signed shorts on the coldfire is that I saw in the assembly it was loading the shorts with zero extend and then doing a 32-bit subtract. I don't think this will give me the correct value so I went to signed shorts and it does. You suggested going to unsigned shorts but I don't think this will work. Am I missing something simple here? Thanks, At 12:00 AM 9/15/2008 -0500, coldfire@... wrote: >From: "Mark Butcher" <Mark@...> >To: <coldfire@...> >Subject: AW: [ColdFire] Re: Digest from coldfire@... >Date: Sun, 14 Sep 2008 22:57:40 +0200 > >Hi Bob >Just a side note. I work with several compilers and the CW warnings are in >fact quite extreme and I do in fact keep them off since otherwise the >casting required also becomes rather extreme. >My solution is to compile the project with GCC and Visual-Studio >and ensure that they don't give any warnings - assuming that this is the >case, then I am satisfied. >Regards >Mark > > > >-----Ursprüngliche Nachricht----- >Von: coldfire-bounce@... [mailto:coldfire-bounce@...] Im >Auftrag von Robert Ritchey >Gesendet: Sonntag, 14. September 2008 16:44 >An: mark@... >Betreff: [ColdFire] Re: Digest from coldfire@... > >Hi Mark, >Thank you very much for the detailed explanation. Its very clear now. >I think with this help I can make some informed decisions on how to >declare variable types. > > > > >typedef struct > > { > > short RiseEdge; /* Pulse rising > >edge time */ > > short FallEdge; /* Pulse > >falling edge time */ > > } ChanInStruct; > > > >bool TxPulseOffset(short *Offset) > >{ > > short PulseWidth; > > /* Pulse width */ > > PulseWidth = (short)(pRxChannelInput->FallEdge - > >pRxChannelInput->RiseEdge); /* Pulse width is falling minus rising >*/ > >} -Bob -------------------------------------------------------------------- Robert Ritchey Quest Engineering & Development, Inc. Suite B/8 6125 South Ash Avenue Tempe, AZ 85283 Tel: (480) 460-2652 FAX: (480) 460-2653 E-Mail: RRRitchey@... E-Mail: RRRitchey@... E-Mail: RRRitchey@... E-Mail: RRRitchey@... WWW: www.QuestEngDev.com/ WWW: www.Smart-Fly.com/ -------------------------------------------------------------------- --- coldfire@... Send a post to the list. coldfire-join@... Join the list. coldfire-digest@... Join the list in digest mode. coldfire-leave@... Leave the list. --- coldfire@... Send a post to the list. coldfire-join@... Join the list. coldfire-digest@... Join the list in digest mode. coldfire-leave@... Leave the list. |
|
|
Re: Re: Digest from coldfire@wildrice.comRobert
I developped a device based on pulse measurement with 52223 and so I needed to handle with captures. Although I´m also a "original" hw guy (concerned on bits/bytes etc) , I concluded that many times is not worth manipulate variables smaller then 32bits in machines like ColdFire.The "price" is the same For my application, wich seems to be similar with your, I (lazily?) did sonething like this: uint32 current_value uint32 new_value uint32 old_value_value current_value="hw_counter" // (MCF..... if(old_value>=current_value) { new_value=old_value-current_value; } else { new_value=current_value-old_value; } old_value=current_value; This code runs in the interrupt_routine. Good luck ... Ricardo Raupp ----- Original Message ----- From: "Robert Ritchey" <RRRitchey@...> To: "Ricardo" <ricardo@...> Sent: Monday, September 15, 2008 11:32 AM Subject: [ColdFire] Re: Digest from coldfire@... Hi Mark, Thanks for that too. I am afraid I am mostly a hardware guy so this is about the only C compiler I have right now. In the past I did most of my work in assembly on the MSP430. Which brings me to one last question if I could impose. Basically what I am doing here is capturing a pulse by a time to determine the pulse width. I capture the rising and falling edges on a counter that is modulo 16 bits. The MSP430 is a 16-bit machine so to get the pulse width I just subtracted the falling edge from the rising edge value and got a positive value. The reason I went to signed shorts on the coldfire is that I saw in the assembly it was loading the shorts with zero extend and then doing a 32-bit subtract. I don't think this will give me the correct value so I went to signed shorts and it does. You suggested going to unsigned shorts but I don't think this will work. Am I missing something simple here? Thanks, At 12:00 AM 9/15/2008 -0500, coldfire@... wrote: >From: "Mark Butcher" <Mark@...> >To: <coldfire@...> >Subject: AW: [ColdFire] Re: Digest from coldfire@... >Date: Sun, 14 Sep 2008 22:57:40 +0200 > >Hi Bob >Just a side note. I work with several compilers and the CW warnings are in >fact quite extreme and I do in fact keep them off since otherwise the >casting required also becomes rather extreme. >My solution is to compile the project with GCC and Visual-Studio >C-compilers >and ensure that they don't give any warnings - assuming that this is the >case, then I am satisfied. >Regards >Mark > > > >-----Ursprüngliche Nachricht----- >Von: coldfire-bounce@... [mailto:coldfire-bounce@...] Im >Auftrag von Robert Ritchey >Gesendet: Sonntag, 14. September 2008 16:44 >An: mark@... >Betreff: [ColdFire] Re: Digest from coldfire@... > >Hi Mark, >Thank you very much for the detailed explanation. Its very clear now. >I think with this help I can make some informed decisions on how to >declare variable types. > > > > >typedef struct > > { > > short RiseEdge; /* Pulse rising > >edge time */ > > short FallEdge; /* Pulse > >falling edge time */ > > } ChanInStruct; > > > >bool TxPulseOffset(short *Offset) > >{ > > short PulseWidth; > > /* Pulse width */ > > PulseWidth = (short)(pRxChannelInput->FallEdge - > >pRxChannelInput->RiseEdge); /* Pulse width is falling minus rising >*/ > >} -Bob -------------------------------------------------------------------- Robert Ritchey Quest Engineering & Development, Inc. Suite B/8 6125 South Ash Avenue Tempe, AZ 85283 Tel: (480) 460-2652 FAX: (480) 460-2653 E-Mail: RRRitchey@... E-Mail: RRRitchey@... E-Mail: RRRitchey@... E-Mail: RRRitchey@... WWW: www.QuestEngDev.com/ WWW: www.Smart-Fly.com/ -------------------------------------------------------------------- --- coldfire@... Send a post to the list. coldfire-join@... Join the list. coldfire-digest@... Join the list in digest mode. coldfire-leave@... Leave the list. __________ NOD32 3442 (20080915) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.com --- coldfire@... Send a post to the list. coldfire-join@... Join the list. coldfire-digest@... Join the list in digest mode. coldfire-leave@... Leave the list. |
| Free embeddable forum powered by Nabble | Forum Help |