Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

R1861: 8051 UART send data problem

2 posters

Go to page : Previous  1, 2

Go down  Message [Page 2 of 2]

26R1861: 8051 UART send data problem - Page 2 Empty Re: R1861: 8051 UART send data problem Fri Oct 06, 2023 4:03 am

royqh1979



arcachofo wrote:Check R1973:
Sender is enabled at first write to SBUF.

Not sure if there is still some other issue, but this fixes  the wrong byte sent at reset.

Though I still think an extra prop is a natural way to handle this, I think what you've done IS a brilliant solution.

As for the reset and initialization, I think that any design that depends on the correct order of registers assignment,that is, reg X must be inited before reg Y,  is not a good one and may introduce subtle errors. So the UART sender/receiver should be turned off BEFORE the register initialization.

27R1861: 8051 UART send data problem - Page 2 Empty Re: R1861: 8051 UART send data problem Fri Oct 06, 2023 12:59 pm

arcachofo

arcachofo

Though I still think an extra prop is a natural way to handle this, I think what you've done IS a brilliant solution.
Thank you.
An extra prop for a single special case is a bit of an overkill in my opinion, if we had several cases like this maybe it is worth to add it.

A bit of an off topic, but related to this:
At this point i'm sure you know that I'm obsessed with simplicity.
So I don't add a single line of code if not absolutely necessary.
And I don't add features that are not important if they take more than a few lines of code.

Maybe a company or some organization can afford to have a huge bloated source code, but this is not the case.
I have seen several projects to die or struggle because they keep adding code as if there were no tomorrow and after a few years there is no human way to keep it unless there is an organized team of several developers, testers, graphic designer, texter, video editor, manager, etc.

So the UART sender/receiver should be turned off BEFORE the register initialization.
Sender is disabled at I51Usart::reset().

28R1861: 8051 UART send data problem - Page 2 Empty Re: R1861: 8051 UART send data problem Fri Oct 06, 2023 2:04 pm

royqh1979



arcachofo wrote:
A bit of an off topic, but related to this:
At this point i'm sure you know that I'm obsessed with simplicity.
So I don't add a single line of code if not absolutely necessary.
And I don't add features that are not important if they take more than a few lines of code.

en...Basically I agree you and I did have learned a lot from simulide.

But...maybe I have a slightly different unstanding about simpilicity from yours? I thought that simplicity means not only fewer unnecessary functions and code lines, but also codes that more easy to read and understand. So I would prefer solutions that seems more intuitive, though they may need more codes to implement... Anyway, I know what you mean and I'll try to stick to it.

29R1861: 8051 UART send data problem - Page 2 Empty Re: R1861: 8051 UART send data problem Fri Oct 06, 2023 3:21 pm

arcachofo

arcachofo

I thought that simplicity means not only fewer unnecessary functions and code lines, but also codes that more easy to read and understand. So I would prefer solutions that seems more intuitive, though they may need more codes to implement
Yes, I agree with that.
But in each case there is a decision to make.
Implementing a general solution for a single special case does not seem good to me.

And there are other solutions that could be implemented without adding a property to all registers.
Indeed I'm testing this one:
- There is a new function eMcu::state() (substitutes eMcu::isSleeping())
- At eMcu::reset() state is set to mcuStopped
- At I51Usart::sendByte() it checks if eMcu::state() == mcuStopped to send byte or not
- 8051 UART sender is enabled at I51Usart::reset()

eMcu::state() is also used by interrupts to check it MCU is sleeping and could be useful in other cases.

Pushed at Rev 1976.

What do you think?

30R1861: 8051 UART send data problem - Page 2 Empty Re: R1861: 8051 UART send data problem Sat Oct 07, 2023 3:41 am

royqh1979



arcachofo wrote:
I thought that simplicity means not only fewer unnecessary functions and code lines, but also codes that more easy to read and understand. So I would prefer solutions that seems more intuitive, though they may need more codes to implement
Yes, I agree with that.
But in each case there is a decision to make.
Implementing a general solution for a single special case does not seem good to me.

And there are other solutions that could be implemented without adding a property to all registers.
Indeed I'm testing this one:
- There is a new function eMcu::state() (substitutes eMcu::isSleeping())
- At eMcu::reset() state is set to mcuStopped
- At I51Usart::sendByte() it checks if eMcu::state() == mcuStopped to send byte or not
- 8051 UART sender is enabled at I51Usart::reset()

eMcu::state() is also used by interrupts to check it MCU is sleeping and could be useful in other cases.

Pushed at Rev 1976.

What do you think?

Yeah. I've tested it and think this is a good and natural solution.

arcachofo likes this post

Sponsored content



Back to top  Message [Page 2 of 2]

Go to page : Previous  1, 2

Permissions in this forum:
You cannot reply to topics in this forum