PDA

View Full Version : USART on 16F627



electronicsuk
- 30th November 2004, 14:55
Hi all. I've just finished soldering up four PCB's for a serially controlled switch box. I'm using the UART for receiving data, but I don't need to transmit so decided to use portb.2 (TX on the 16F627) as an output pin to my triac isolators. However, whenever the serial port is enabled this pin is constantly set high. Is there any way on this PIC to turn on serial reception without enabling the transmit pin?

There is absolutely no way I can resolder the PCB's, as the boards have now been cased up and the triacs (isolated tab of course!) riveted to the metal casing for use as a heatsink :(

Thanks,

Matthew

Ingvar
- 30th November 2004, 17:13
Hi Matthew,

I looked over the datasheet and can't see any way to take control over this pin if the USART is enabled. If you're planning on triggering the triac with low pulses you might get away with this pin afterall. If you transmit $ff that will simply be one low pulse, 1/baudrate long(1/9600=0.1ms). If this is not possible, you need to disable the USART and go softwareserial instead.

/Ingvar

electronicsuk
- 30th November 2004, 17:19
Thanks for the help. Unfortunately I can't go with software, this thing also does dimming and I need to use hardware serial so I can carry on with my dimming routine at the same time. I do have a spare i/o so unless anyone has any other suggestions, I will just have to solder a jump wire on the chip itself, seen as I can't get to the underside of the PCB any more. One thing that the chip does allow is for you to disable the TX pin by setting it as an input, but unfortunately I need it as a standard output.

Matthew

electronicsuk
- 30th November 2004, 18:19
Think I've sorted this one now, rather than sending the port low, I'm just having to set it as an input which does practically the same job. It's a bit kludgy but it seems to work. Let's just hope that the 627 doesn't mind having a pin changed between input and output around 100 times a second!

Matthew

Ingvar
- 1st December 2004, 01:45
Hi Matthew,

Good to hear that you've come up with a possible solution.

Just make sure that you don't need a pullup or pulldown, if you connect directly to a triac or optocoupler(led) there shouldn't be any need for it. If you connect to a FET or MOSFET (ic or discrete) you probably will need one.

The Pic will not have any problems with toggling between input and output, it's basically the same as toggling the output buffer, i've done it many times to emulate an open collector output. No problems whatsoever, ever.

I did find a statements in the datasheet that led my mind in the direction that it could be possible to set the pin to input. However, quite often i find that there are small errors in the datasheets, usually in the text. The blockdiagrams that shows the internal configuration of each pin are usually more accurate. Not in this case, it seems, according to that figure it should be impossible to do what you're doing. Keep this in mind if you plan to migrate to another pic(16F627A or 16F628), it's easy to assume that they should behave identical, but there is no guarantee.

Good luck
/Ingvar