Reply by Michael Anton December 2, 20102010-12-02
> -----Original Message-----
> From: l...
> [mailto:l...]On Behalf Of zied130187
> Sent: Thursday, December 02, 2010 10:23 AM
> To: l...
> Subject: [lpc2000] Re: problem UART - LPC2129 - kit olimex
>
> hello, thank you for your response
> when i use this instruction
> U0THR = character_value(dat);
> in IAR you can see the value of any register in the window register
> without use any function
> and the value of U0THR ahter my instruction is 0xFF and not 0x41
>
> i don't understand why the register don't change in value 0x41

Because it is a write only register. You cannot read the value back
via any means. This includes not being able to read it via the IAR
register window. It is not possible.

If you do read it, you are reading U0RDR, which is the recieve data
register (as U0THR, and U0RDR share the same address). So you will
get data recieved by the UART, not what you sent.

Mike

An Engineer's Guide to the LPC2100 Series

Reply by zied130187 December 2, 20102010-12-02
--- In l..., "roelof 't Hooft" wrote:
>
> Hi Zied,
>
> On Thu, 2010-12-02 at 15:22 +0000, zied130187 wrote:
> > void UART0_SendByte (char dat)
> > {
> > unsigned char salut;
> > U0IER |= 0x02; // enable tx interrupt
> > printf("data0 %c\n",dat);
> > while (!(U0LSR & 0x20));
> > salut = character_value(dat);
> > printf("salut = %X\n",salut); // display 0x41 when dat = 'A'
> > U0THR = character_value(dat); // in register windows of IAR
> > // U0THR change value to 0xFF not
> > //to 0x41 when i send 'A'
> > printf ("U0TX = %X\n",U0THR);
> > A_LED2_OFF;
> > }
>
> Questions :
> - Why do you use printf() if you are looking at the
> disassembly window in IAR ?
> - Where is the output of printf() going, uart0 or uart1 ?
> - Are you sure that you did not create a "race condition"
> by putting a printf() within UART0_SendByte() ?
>
> These questions and your answers are more for you than for me.
>
> I am not a big fan of printf() in embedded programming
> because it uses a LOT of memory. True, there are versions
> specifically for embedded programming which are a much
> more friendly on the memory usage.
> I try to write my own routines like uart0_putstring() and
> uart0_puthex().
>
> roelof
>
hello, thank you for your response
when i use this instruction
U0THR = character_value(dat);
in IAR you can see the value of any register in the window register
without use any function
and the value of U0THR ahter my instruction is 0xFF and not 0x41

i don't understand why the register don't change in value 0x41

what is the type of var i must affect to character_value(dat)

unsigned char, no ?

Reply by roelof 't Hooft December 2, 20102010-12-02
Hi Zied,

On Thu, 2010-12-02 at 15:22 +0000, zied130187 wrote:
> void UART0_SendByte (char dat)
> {
> unsigned char salut;
> U0IER |= 0x02; // enable tx interrupt
> printf("data0 %c\n",dat);
> while (!(U0LSR & 0x20));
> salut = character_value(dat);
> printf("salut = %X\n",salut); // display 0x41 when dat = 'A'
> U0THR = character_value(dat); // in register windows of IAR
> // U0THR change value to 0xFF not
> //to 0x41 when i send 'A'
> printf ("U0TX = %X\n",U0THR);
> A_LED2_OFF;
> }

Questions :
- Why do you use printf() if you are looking at the
disassembly window in IAR ?
- Where is the output of printf() going, uart0 or uart1 ?
- Are you sure that you did not create a "race condition"
by putting a printf() within UART0_SendByte() ?

These questions and your answers are more for you than for me.

I am not a big fan of printf() in embedded programming
because it uses a LOT of memory. True, there are versions
specifically for embedded programming which are a much
more friendly on the memory usage.
I try to write my own routines like uart0_putstring() and
uart0_puthex().

roelof

Reply by roelof 't Hooft December 2, 20102010-12-02
Hi Zied,

On Thu, 2010-12-02 at 15:22 +0000, zied130187 wrote:
> my problem is :
>
> when i transmit 0x41 value in unsigned char salut
> IAR workbench display change value of salut to 0x41
>
> but when i change U0THR with value 0x41
> IAR workbnech in windows register UART0
> U0THR change value to 0xFF !!!!!!!!!!!
>
> i don't understand why U0THR not change to 0x41.

PLEASE read page 132 of the user manual um10114 (v3
2 april 2008) again !
Paragraph 4.1 and 4.2 will tell you all you need to
know about your question.
> this is the code for send byte :

snip

> please any idea ?

Please read my first response again !

roelof

Reply by Dave Such December 2, 20102010-12-02
U0THR is a write only register. Reads are invalid.
On 12/2/2010 10:22 AM, zied130187 wrote:
>
> --- In l... ,
> "roelof 't Hooft" wrote:
> >
> > On Thu, 2010-12-02 at 10:05 +0000, zied130187 wrote:
> >
> > Hi Zied,
> >
> > > hello Roelof why name is Zied
> > >
> > > who i can display the value of I0Pin ?
> >
> > You van use a LED, scope or logic analyzer.
> > Or use a program like minicom running on a PC.
> >
> > roelof
> > my problem is :
>
> when i transmit 0x41 value in unsigned char salut
> IAR workbench display change value of salut to 0x41
>
> but when i change U0THR with value 0x41
> IAR workbnech in windows register UART0
> U0THR change value to 0xFF !!!!!!!!!!!
>
> i don't understand why U0THR not change to 0x41.
>
> this is the code for send byte :
>
> void UART0_SendByte (char dat)
> {
> unsigned char salut;
> U0IER |= 0x02; // enable tx interrupt
> printf("data0 %c\n",dat);
> while (!(U0LSR & 0x20));
> salut = character_value(dat);
> printf("salut = %X\n",salut); // display 0x41 when dat = 'A'
> U0THR = character_value(dat); // in register windows of IAR
> // U0THR change value to 0xFF not
> //to 0x41 when i send 'A'
> printf ("U0TX = %X\n",U0THR);
> A_LED2_OFF;
>
> }
>
> please any idea ?
Reply by zied130187 December 2, 20102010-12-02
--- In l..., "roelof 't Hooft" wrote:
>
> On Thu, 2010-12-02 at 10:05 +0000, zied130187 wrote:
>
> Hi Zied,
>
> > hello Roelof why name is Zied
> >
> > who i can display the value of I0Pin ?
>
> You van use a LED, scope or logic analyzer.
> Or use a program like minicom running on a PC.
>
> roelof
>
my problem is :

when i transmit 0x41 value in unsigned char salut
IAR workbench display change value of salut to 0x41

but when i change U0THR with value 0x41
IAR workbnech in windows register UART0
U0THR change value to 0xFF !!!!!!!!!!!

i don't understand why U0THR not change to 0x41.

this is the code for send byte :

void UART0_SendByte (char dat)
{
unsigned char salut;
U0IER |= 0x02; // enable tx interrupt
printf("data0 %c\n",dat);
while (!(U0LSR & 0x20));
salut = character_value(dat);
printf("salut = %X\n",salut); // display 0x41 when dat = 'A'
U0THR = character_value(dat); // in register windows of IAR
// U0THR change value to 0xFF not
//to 0x41 when i send 'A'
printf ("U0TX = %X\n",U0THR);
A_LED2_OFF;

}

please any idea ?

Reply by roelof 't Hooft December 2, 20102010-12-02
On Thu, 2010-12-02 at 10:05 +0000, zied130187 wrote:

Hi Zied,

> hello Roelof why name is Zied
>
> who i can display the value of I0Pin ?

You van use a LED, scope or logic analyzer.
Or use a program like minicom running on a PC.

roelof

Reply by zied130187 December 2, 20102010-12-02
--- In l..., "roelof 't Hooft" wrote:
>
> Hi what is your name,
>
> u0thr and u0rbr share the same address and are
> respectively read only and write only (dlab == 0).
>
> If you really want to check if you have done it
> correct you might want to look at the IO pin for
> the serial data coming out the uart.
>
> roelof
> On Thu, 2010-12-02 at 09:30 +0000, zied130187 wrote:
> > hello,
> >
> > when i send data in U0THR
> >
> > U0THR = 0x41;
> > printf ("U0THR = %X\n",U0THR);
> >
> > IAR display U0THR = FF
> >
> > why U0THR have FF value and don't have 41 value ?
>

hello Roelof why name is Zied

who i can display the value of I0Pin ?

Reply by roelof 't Hooft December 2, 20102010-12-02
On Thu, 2010-12-02 at 10:46 +0100, roelof 't Hooft wrote:
> Hi what is your name,
>
> u0thr and u0rbr share the same address and are
> respectively read only and write only (dlab == 0).

Oh crap, make that write only and read only.

roelof

Reply by roelof 't Hooft December 2, 20102010-12-02
Hi what is your name,

u0thr and u0rbr share the same address and are
respectively read only and write only (dlab == 0).

If you really want to check if you have done it
correct you might want to look at the IO pin for
the serial data coming out the uart.

roelof
On Thu, 2010-12-02 at 09:30 +0000, zied130187 wrote:
> hello,
>
> when i send data in U0THR
>
> U0THR = 0x41;
> printf ("U0THR = %X\n",U0THR);
>
> IAR display U0THR = FF
>
> why U0THR have FF value and don't have 41 value ?