Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Zap

Pages: [1]
1
Programming Questions / Bi directional port in a library example?
« on: October 31, 2011, 11:18:30 PM »

I am useing port 2 on my DIY wiring board as a bi directional port (bus) and works fine accessing it using a sketch such as below. (port 1 is used as the chip /latch select)

// function getiptbyte gets the data byte on the input latch
byte getiptbyte (){
  portMode(2, INPUT);       // flips the bus port to input
  portWrite(1, 0x80);       // sets the latch for the input buffer
  ipt = portRead (2);       // reads the data on the buss port
  portWrite(1, 0x00);        // turns off the input latch
  portMode(2, OUTPUT);      // resets the bus port to output
  return ipt;
}

However when I try to move this into a class library (As below) it does not read the data on the bus for some reason. Is this the correct way to manipulate the portmode in a libary? and is there any example librarys with a port being used as Bi-directional?

 // member: getiptbyte gets the data byte on the input latch
byte iWire::getiptbyte (){
  portMode(2, INPUT);       // flips the bus port to input
  portWrite(1, 0x80);       // sets the latch for the input buffer
  ipt = portRead (2);       // reads the data on the buss port
  portWrite(1, 0x00);       // turns off the input latch
  portMode(2, OUTPUT);      // resets the bus port to output
//  ipt = (0xAA);           // Used only to test that the return works.
  return ipt;
}


Thanks Zap.
2

Some time ago I built up a number of atmega128 wireing boards of my own requirements and have been using a v2.x auto reset bootloader sucessfully under Wiring 0027. Firmware from here http://www.avride.com/article/wiring/ burnt using AVRstudio and a mkII isp.

I have now upgraded to Wiring 0100 IDE and have noticed that some pins do not operate as previously ( same shetch in both IDE's). Two pins in question are I/O 27 & 28 (PB3 & PB4) do not work however I/O 31 (PB7) is OK. (note not all pins tested as these boards do not use all of them)
In IDE 0100 I am useing Board / Wiring / Wiring V1.0/Wiring Mini @16mhz as this appears to be the closest choice for this hardware.

What do I need to do to use wiring IDE 0100 corectly with these boards?

Thanks Zap.
Pages: [1]