This week I am rewriting the read and write functions in C programming for UART. Dr Shawn really taught me a lot about the easy and correct way to write the codes.

Next I need to make sure that the information are stored to the respective address correctly when the instructions are called. For this case, an objectMapping object will be created in JavaScript to map the address and values. However, the object mapping object was not created by the JavaScript when I first perform testing on the simulator. I was confused and tried to track how the objectMapping is created. Finally, I figured out what happened. For Uart, Mspi and Twi, they transmit or receive data in bytes, and this is why the objectMapping is not created. The current objectMapping perform load/store in word and not byte (LW/SW). As a result,  when using write function to store a value, the objectMapping will not be available as it is just for LW/SW.

In order to solve this problem, I referred to the LW and SW case and tried to implement the objectMapping method to LB (Load Byte) and SB (Store Byte). It actually did worked as expected.

Next I will have to configure the status register flags, where I need to set or clear certain flags of data register when read/write function is called. In actual world, the uart transfer data bit by bit, so it might take some time to finish the data transmission and would require constant checking for the status register. However, in simulator, the transfer speed is a lot faster. So what I need to do is just set or clear the related flags according to the actions (either read or write data).

That is all for this week.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.