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 ?
this is function of initialization of UART0
void UART0Init(U16 baud)
{
U16 divisor = getperipheralClockFreq() / (16 * baud);
U0LCR_bit.DLAB=1; //Enable DLAB
U0LCR_bit.WLS=3; //8 bits
U0LCR_bit.SBS=1; //1 stop bit
U0DLL = LSB(divisor);
U0DLM = MSB(divisor);
U0LCR_bit.DLAB=0; //Disable DLAB
/* U0FCR: UART0 FIFO Control Register
0x05: Clear Tx FIFO and enable Rx and Tx FIFOs */
U0FCR=0x07 ;
PINSEL0_bit.P0_0=1;
PINSEL0_bit.P0_1=1;
}
i have cleared Tx FIFO , what is the problem ?
help me please
problem UART - LPC2129 - kit olimex
Started by ●December 2, 2010
Reply by ●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 ?
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 ?
Reply by ●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
> 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 ●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 ?
>
> 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 ●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
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 ●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 ?
>
> 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 ●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 ?
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 ●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
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 ●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
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 ●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 ?
>
> 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 ?