??? 12/30/06 12:51 Modified: 12/30/06 12:59 Read: times |
#130243 - answer is partially incorrect Responding to: ???'s previous message |
Russel,
I don't want to score your message as incorrect because it has many good points, but the last one about atomicity is incorrect. mov a, TX_BUF_HEAD ;TX_BUF_HEAD is not changed in the ISR xrl a, TX_BUF_TAIL ;this is an atomic read JZ TX_BUF_EMPTY_TEST TX_BUF_NOT_EMPTY: mov R0, TX_BUF_HEAD mov @R0, TX_DB inc TX_BUF_HEAD ;this is an atomic increment anl TX_BUF_HEAD,#31 ;loop around Only TX_BUF_TAIL is changed in the ISR and thus needs atomic read access in the main thread. Since it is only 1 byte the read is atomic by design. TX_BUF_HEAD is read in the ISR so updates in the main thread need to be atomic. Since it is also only 1 byte and incremented using inc this is fulfulled too. It will also need an overflow check for buffers <> 256 to make it a ring buffer. If the ISR does this too after the read there is no problem. Maarten |
Topic | Author | Date |
the nature of the UART/steping through interrupts | 01/01/70 00:00 | |
Uart is full duplex | 01/01/70 00:00 | |
Thanks Russell | 01/01/70 00:00 | |
UART Question Part 2 | 01/01/70 00:00 | |
You can not do both | 01/01/70 00:00 | |
In response to Neil | 01/01/70 00:00 | |
go with the bit | 01/01/70 00:00 | |
In response to Neil | 01/01/70 00:00 | |
In response to Neil | 01/01/70 00:00 | |
Sorry for teh tripple post... | 01/01/70 00:00 | |
More... | 01/01/70 00:00 | |
Search and Read | 01/01/70 00:00 | |
Thanks Russell | 01/01/70 00:00 | |
I hope Russell did not lead you down the garden pa | 01/01/70 00:00 | |
Erik - garden path indeed! | 01/01/70 00:00 | |
I'm using interrupts | 01/01/70 00:00 | |
Question about my interrupt driven UART | 01/01/70 00:00 | |
You know the answer. | 01/01/70 00:00 | |
Thanks Russell | 01/01/70 00:00 | |
answer is partially incorrect![]() | 01/01/70 00:00 | |
Can't single step on UART | 01/01/70 00:00 |