sample program written for PicMicro i cannot relate the same code to
OOpic.
void sm130_version(void)
{
I2C_start(); //Send start command
I2C_write(0x42); //Send Slave address
I2C_write(0x01); //Length is 1 byte
I2C_write(0x81); //Version = command 0x81
I2C_write(0x82); //Send checksum
//while zero is read
//{
// Send stop() if zero is read
//}
//Read in length byte
//Read in "LENGTH" number of bytes
//Send stop()
}
======================================================================
While running my code the oopic seem to run only the first line when
it enter the GetFirmware() function
oLED redled = New oLED;
oLED yellowled = New oLED;
oLED greenled = New oLED;
oSpeaker Spk = New oSpeaker;
oDIO1 Dipswitch = New oDIO1;
oI2CM Ports = New oI2CM;
oDIO1 dataready = New oDIO1;
Void Main(Void){
Setup();
//RFOn(); //turn on rf field
GetFirmware();
//RFOff(); //turn off rf field
ooPIC.Delay = 10000;
}
Void Setup()
{
//set up I2C ports
Ports.Node = &h84;
Ports.NoInc = cvTrue;
Ports.Mode = cv7Bit;
Ports.Width = cv16Bit;
//initialize 3 led and default them off
redled.IOLine = 7;
yellowled.IOLine = 6;
greenled.IOLine = 5;
redled.TurnOff;
yellowled.TurnOff;
greenled.TurnOff;
//at start only yellow led is on
//with acknoledge on sound sequence
yellowled.TurnOn;
Spk.Beep(65000,100);
ooPIC.Delay = 1000;
//set up a dipswitch and other I/O
ooPIC.PullUp = cvTrue;
Dipswitch.IOLine = 8;
Dipswitch.Direction = cvInput;
dataready.IOLine = 9;
dataready.Direction = cvInput;
}
Void GetFirmware()
{
//greenled.TurnOn; When uncommenting this. Only this command run
Ports.Value=&h81;
//Ports.Value=&h83;
//Ports.Value=&h84;
greenled.TurnOn;
ooPIC.Delay = 10000;
For(Int x=0;x<=10000;x++)
{
greenled.TurnOn;
ooPIC.Delay = 500;
If (dataready == cvTrue)
{
greenled.TurnOn;
Spk.Beep(64000,100);
Break;
}
greenled.TurnOff;
}
Ports.Node=&h85;
Int length;
Do
{
length = Ports.Value;
}
While(length == &hFF Or length ==&h00);
If(length == &h08)
redled.TurnOn;
ooPIC.Delay = 5000;
If(Ports.Value == &h00)
redled.TurnOff;
ooPIC.Delay = 5000;
}
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/oopic/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/oopic/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
No comments:
Post a Comment