PDA

View Full Version : Serial addressing



electronicsuk
- 17th June 2005, 22:01
Hi everyone. Looking at the documentation for PIC micros such as the 16F627 and 16F877, its possible to use a 9th bit for addressing purposes so that an interrupt will only be generated by the UART on address bytes. This is useful, but are there any PIC micros that has a specific register set aside for an address byte, and will compare this to the data on the serial line and only generate an interrupt when they match?

Cheers,

Matt

DynamoBen
- 17th June 2005, 22:50
From everything I have read the 9th bit is the only option. If you don't do 9th bit then you have to do it in software.

electronicsuk
- 18th June 2005, 11:20
Thats a shame, as it would mean a lot less work from a design point of view if microchip implemented a proper hardware address detect and compare. I'll just have to go with 9th bit, it still frees up more CPU time than having to validate every byte of data the UART receives. Cheers.

DynamoBen
- 18th June 2005, 18:24
The problem is making the UART aware of the fact that a byte in the data packet is an address. With most protocols the address is not the first byte. It would be very complex to implement that.

The "hard way" is not too bad. I'm doing a project now that responds to the node address and 00 as a multicase discovery address. Its not too bad.

electronicsuk
- 18th June 2005, 22:16
I agree it would be more complicated to do address detect without the 9th bit, but it would be relatively easy to keep the 9th bit system but also to have the PIC compare the received address to one with a register, and ignore any addresses not designated for that particular micro.

Alternatively design a protocol where the address bytes can never occur as a data byte, for example all decimal values above 100 can be used for addressing only. The trouble I had before with this system is that every time the UART received a byte of data, it would have to be read and checked to see if it was an address, even if it was only a data byte. There was absolutely no way of knowing without reading the data.

On its own this wouldn't be a problem, but at the same time I'm keeping an eye on a zero crossing detector and driving 8 triac dimming outputs. When sending out large amounts of data the lamps being driven by the triacs would flicker slightly as the micro was having to take some time out from the dimming routine, go read the UART and make a comparison.