??? 08/02/08 04:37 Read: times |
#157235 - Silabs - Port Configuration - f04x |
Hi there all - Will cross post this at Silabs....
I have a Silabs f047 device, with no external pullups on any of the ports. I am using P2 as a device address with DIP switches to ground, when the DIP switch is closed. P1 is spare and goes out to a 5x2 pin header. P3 drives 3 LEDs and an enable line for a H-Bridge Motor driver P0 has a PWM output and a few inputs, (TACT switches and Reed switches) as well as another enable line for the H-Bridge. All is rosy (fine) when the DIP switch is grounded. When more than 2 or 3 of the switches are open nothing works - the motor will not operate, and the TACT and reed switches are incorrectly interpreted. I was assuming that the internal pullups would still be operational and would pull the open inputs whether this is a TACT, DIP or reed switch to a "logic 1" hence no external pullups have been fitted. However on carefully reading the datasheet (page 206 section 17.1.2) it states. "In the open drain configuration, writing a logic 0 to the associated bit in the port data register will cause the port pin to be driven to ground , and a logic 1 will cause the port pin to assume a HIGH IMPEDENCE state" Hmmm - I thought to myself, does this then mean that I need external pullups on all inputs, if I want to clamp them at a known input level? Is this why having the DIP switches open (ie HiZ) causes the other HiZ inputs to get messed up? Ie when I press the Open Tact Switch, the close button code gets run instead. It is driving me nuts, Is there a more definitive way of ensuring that the pins used as inputs are held high by way of the internal pullups? (about 100k according to the datasheet) Should I have external pullups on all inputs when using this chip in the future. Also by the way I found an app-note (AN101) from silabs that said this: "Unlike the standard 8051, true push-pull outputs are provided. If the 'strong-then-weak' pull-up function of the 8051 is required, it can be emulated in software by configuring the associated port output as 'push-pull' followed by a configuration to 'open-drain' " Is this what will solve my woes? I tried it on the DIP to no avail. but am a little wary as the data sheet indicates that the push-pull configuration is connected directly to VDD, so having the DIP closed (to ground) means lots of current through that port.....poof Here is my port config - sorry it is messy I have been trying to figure this out. SFRPAGE = CONFIG_PAGE; P0MDOUT = 0x31; P1MDOUT = 0x07; //no point configuring this it is spare // P1MDOUT = 0xFF; //no point configuring this it is spare P2MDIN = 0xFF; //this is the default for Open drain inputs P2MDOUT = 0x00; //this is the default for Open drain inputs P2 = 0xFF; //write ones to the port to ensure it is an input P3MDOUT = 0x0F; XBR0 = 0x14; //PCA 0 & 1 to port pins, UART0 to port pins //XBR1 = 0x14; //Int0 & Int1 to port pins XBR3 = 0x80; //CAN is push pull XBR2 = 0x44; //uart 1 to port pins, enable XBAR Thanks for any thoughts, I hope I have given enough detail, please let me know if you require anything further. Regards Marshall Brown |
Topic | Author | Date |
Silabs - Port Configuration - f04x | 01/01/70 00:00 | |
Further info | 01/01/70 00:00 | |
Found it![]() | 01/01/70 00:00 |