Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

codevision putchar()

codevision putchar()

2005-10-09 by Aaron

I'm attempting to use the Codevision compiler with a tiny2313.  
Unfortunately its been 7 years since I took C, so I'm quite rusty...

While I wait for the moderator of the codevisionavr group to approve my 
membership, I will post my question here. :)

If I write:
   putchar (0x55)   ; transmit ascii U out the serial port
it works as expected.

But if I write:
   putchar ("U")   ; transmit ascii U out the serial port
it throws a "possible loss of precision" warning and actually transmits 
ascii 8.

What am I missing?

Aaron

Re: [AVR-Chat] codevision putchar()

2005-10-09 by James Hatley

try 'U' ( single quotes )

Jim
----- Original Message ----- 
Show quoted textHide quoted text
From: "Aaron" <aaron.groups@gmail.com>
To: <AVR-Chat@yahoogroups.com>
Sent: Sunday, October 09, 2005 1:46 PM
Subject: [AVR-Chat] codevision putchar()


> I'm attempting to use the Codevision compiler with a tiny2313.
> Unfortunately its been 7 years since I took C, so I'm quite rusty...
>
> While I wait for the moderator of the codevisionavr group to approve my
> membership, I will post my question here. :)
>
> If I write:
>    putchar (0x55)   ; transmit ascii U out the serial port
> it works as expected.
>
> But if I write:
>    putchar ("U")   ; transmit ascii U out the serial port
> it throws a "possible loss of precision" warning and actually transmits
> ascii 8.
>
> What am I missing?
>
> Aaron
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>

Re: [AVR-Chat] codevision putchar()

2005-10-10 by Thomas Keller

On Sun, 2005-10-09 at 16:46 -0400, Aaron wrote:
> I'm attempting to use the Codevision compiler with a tiny2313.  
> While I wait for the moderator of the codevisionavr group to approve
> my membership, I will post my question here. :)
> If I write:
>    putchar (0x55)   ; transmit ascii U out the serial port
> it works as expected.
> But if I write:
>    putchar ("U")   ; transmit ascii U out the serial port
> it throws a "possible loss of precision" warning and actually
> transmits 
> ascii 8.
> What am I missing?

   A working C compiler in my not so humble opinion. 

Tom

Re: [AVR-Chat] codevision putchar()

2005-10-10 by Ralph Hilton

On Mon, 10 Oct 2005 12:34:52 -0500 you wrote:

>On Sun, 2005-10-09 at 16:46 -0400, Aaron wrote:
>> I'm attempting to use the Codevision compiler with a tiny2313.  
>> While I wait for the moderator of the codevisionavr group to approve
>> my membership, I will post my question here. :)
>> If I write:
>>    putchar (0x55)   ; transmit ascii U out the serial port
>> it works as expected.
>> But if I write:
>>    putchar ("U")   ; transmit ascii U out the serial port
>> it throws a "possible loss of precision" warning and actually
>> transmits 
>> ascii 8.
>> What am I missing?

"U" is a string.
'U' is a character.


--
Ralph Hilton
http://www.ralphhilton.org
C-Meter: http://www.cmeter.org
FZAOINT http://www.fzaoint.net

Re: [AVR-Chat] codevision putchar()

2005-10-10 by Aaron

Ralph Hilton wrote:

>
>"U" is a string.
>'U' is a character.
>
>  
>
Thanks to you and the other person who pointed this out.

Aaron

Re: [AVR-Chat] codevision putchar()

2005-10-10 by Aaron

Ralph Hilton wrote:

>>On Sun, 2005-10-09 at 16:46 -0400, Aaron wrote:
>>    
>>
>>>if I write:
>>>   putchar ("U")   ; transmit ascii U out the serial port
>>>it throws a "possible loss of precision" warning and actually
>>>transmits 
>>>ascii 8.
>>>What am I missing?
>>>      
>>>
>
>"U" is a string.
>'U' is a character.
>  
>
Still trying to remember my C classes from 7 years ago...

Not that it really matters, but how does "U" evaluate to 0x38?

Aaron

Re: [AVR-Chat] codevision putchar()

2005-10-10 by Dave Hylands

Hi Aaron,

> Not that it really matters, but how does "U" evaluate to 0x38?

Since "U" is a string, the value passed on the stack will be the
pointer to that string.

0x38 is the portion of the pointer that's interpreted as the character to print.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/

Re: [AVR-Chat] codevision putchar()

2005-10-10 by Ralph Hilton

On Mon, 10 Oct 2005 15:34:09 -0400 you wrote:

>Ralph Hilton wrote:
>
>>>On Sun, 2005-10-09 at 16:46 -0400, Aaron wrote:
>>>    
>>>
>>>>if I write:
>>>>   putchar ("U")   ; transmit ascii U out the serial port
>>>>it throws a "possible loss of precision" warning and actually
>>>>transmits 
>>>>ascii 8.
>>>>What am I missing?
>>>>      
>>>>
>>
>>"U" is a string.
>>'U' is a character.
>>  
>>
>Still trying to remember my C classes from 7 years ago...
>
>Not that it really matters, but how does "U" evaluate to 0x38?

Imagine that you have a 500 character string. It would be horribly inefficient to pass the
500 characters to a function. Instead C passes the address of where the characters are
stored. The address is more than one byte. So the compiler gives a message as it truncates
the address down to one byte. Try doing it twice and I think the byte sent will be
different.
--
Ralph Hilton
http://www.ralphhilton.org
C-Meter: http://www.cmeter.org
FZAOINT http://www.fzaoint.net

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.