Discussion forum for the BasicX family of microcontroller chips.
|
What's the best way to read all of portC as a byte? I tried this, but it didn't work (just the lines that I'm having problems with): Dim BUMP As Byte BUMP =3D Register.PORTC Call PutByte(BUMP) All the other PutByte statements in the same routine work fine, but I get nothing from Register.PORTC (assuming that is what Register.PORTC does). I don't get some random # or 0 or anything, its like the PutByte(BUMP) line is never executed. But I know its getting executed because if I do a BUMP =3D 48, then a 0 appears in my terminal. Maybe I'm going about this all wrong with the Register.PORTC. I thought of a way to do it by reading each of the 8 pins manually, then compiling the bits into a byte, but I know the method I came up with is probably not very efficient at all. Thanks! -C http://www.theonespot.com [Non-text portions of this message have been removed] |
|
|
|
----- Original Message ----- From: "Chris H." <> To: <> Sent: Sunday, January 09, 2000 11:45 AM Subject: [BasicX] Reading PortC as a byte > From: "Chris H." <> > > What's the best way to read all of portC as a byte? > > I tried this, but it didn't work (just the lines that I'm having problems with): > > Dim BUMP As Byte > BUMP =3D Register.PORTC > Call PutByte(BUMP) > > All the other PutByte statements in the same routine work fine, but I get nothing from Register.PORTC (assuming that is what Register.PORTC does). I don't get some random # or 0 or anything, its like the PutByte(BUMP) line is never executed. But I know its getting executed because if I do a BUMP =3D 48, then a 0 appears in my terminal. > > Maybe I'm going about this all wrong with the Register.PORTC. I thought of a way to do it by reading each of the 8 pins manually, then compiling the bits into a byte, but I know the method I came up with is probably not very efficient at all. > > Thanks! > > -C > http://www.theonespot.com > [Non-text portions of this message have been removed] > --------------------------- ONElist Sponsor ---------------------------- > > Hey Freelancers: Find your next project through JobSwarm! > You can even make money in your sleep by referring friends. > <a href=" http://clickme.onelist.com/ad/jobswarm1 ">Click Here</a> > > ------------------------------------------------------------------------ |
|
There are three register. names associated with PortC. Look at the list of register names in the documentation. Do you want to read the pins? The direction register? The output values? Gotta have the right name. Also, the 3D shouldn't be there. mwf ----- Original Message ----- From: "Chris H." <> To: <> Sent: Sunday, January 09, 2000 11:45 AM Subject: [BasicX] Reading PortC as a byte > From: "Chris H." <> > > What's the best way to read all of portC as a byte? > > I tried this, but it didn't work (just the lines that I'm having problems with): > > Dim BUMP As Byte > BUMP =3D Register.PORTC > Call PutByte(BUMP) > > All the other PutByte statements in the same routine work fine, but I get nothing from Register.PORTC (assuming that is what Register.PORTC does). I don't get some random # or 0 or anything, its like the PutByte(BUMP) line is never executed. But I know its getting executed because if I do a BUMP =3D 48, then a 0 appears in my terminal. > > Maybe I'm going about this all wrong with the Register.PORTC. I thought of a way to do it by reading each of the 8 pins manually, then compiling the bits into a byte, but I know the method I came up with is probably not very efficient at all. > > Thanks! > > -C > http://www.theonespot.com > [Non-text portions of this message have been removed] > --------------------------- ONElist Sponsor ---------------------------- > > Hey Freelancers: Find your next project through JobSwarm! > You can even make money in your sleep by referring friends. > <a href=" http://clickme.onelist.com/ad/jobswarm1 ">Click Here</a> > > ------------------------------------------------------------------------ |
|
I don't see any reply text. Did you send an attachment? I think the list server removes all attachments, even just text files... -C http://www.theonespot.com ----- Original Message ----- From: Michael Fellinger <> To: <> Sent: Sunday, January 09, 2000 10:58 AM Subject: Re: [BasicX] Reading PortC as a byte > From: "Michael Fellinger" < > ----- Original Message ----- > From: "Chris H." <> > To: <> > Sent: Sunday, January 09, 2000 11:45 AM > Subject: [BasicX] Reading PortC as a byte > > From: "Chris H." <> > > > > What's the best way to read all of portC as a byte? > > > > I tried this, but it didn't work (just the lines that I'm having problems > with): > > > > Dim BUMP As Byte > > BUMP =3D Register.PORTC > > Call PutByte(BUMP) > > > > All the other PutByte statements in the same routine work fine, but I get > nothing from Register.PORTC (assuming that is what Register.PORTC does). I > don't get some random # or 0 or anything, its like the PutByte(BUMP) line is > never executed. But I know its getting executed because if I do a BUMP =3D > 48, then a 0 appears in my terminal. > > > > Maybe I'm going about this all wrong with the Register.PORTC. I thought of > a way to do it by reading each of the 8 pins manually, then compiling the > bits into a byte, but I know the method I came up with is probably not very > efficient at all. > > > > Thanks! > > > > -C > > http://www.theonespot.com > > > > > > [Non-text portions of this message have been removed] > > > > > > --------------------------- ONElist Sponsor ---------------------------- > > > > Hey Freelancers: Find your next project through JobSwarm! > > You can even make money in your sleep by referring friends. > > <a href=" http://clickme.onelist.com/ad/jobswarm1 ">Click Here</a> > > > > ------------------------------------------------------------------------ > > --------------------------- ONElist Sponsor ---------------------------- > > Independent contractors: Find your next project gig through JobSwarm! > You can even make money by referring friends. > <a href=" http://clickme.onelist.com/ad/jobswarm2 ">Click Here</a> > > ------------------------------------------------------------------------ |
|
Register.ddrc is the data direction register. A one in a bit corresponds to an output bit, a zero in the bit corresponds to an input bit. So as to not mess up a port I usually set the bits that I want in this way: const mybit as byte = 16 'bit number 4 register.ddrc = register.ddrc or mybit This would set mybit (bit number 4) as an output, with the rest being inputs. To read a bit in a port, you use the PIN portion of the register bank: data = register.pinc This will read all pins whether they are inputs or outputs. You would have to mask off the bit you wanted unless you want the entire port. Finally the output pins register is register.portc register.portc = data For complete documentation of how the pins work and the register names, please see the Atmel documenation on the 8515 for the BX1 or the 8535 for the BX24. Jack -----Original Message----- From: Chris H. <> To: <> Date: Sunday, January 09, 2000 11:41 AM Subject: [BasicX] Reading PortC as a byte >From: "Chris H." <> > >What's the best way to read all of portC as a byte? > >I tried this, but it didn't work (just the lines that I'm having problems with): > >Dim BUMP As Byte >BUMP =3D Register.PORTC >Call PutByte(BUMP) > >All the other PutByte statements in the same routine work fine, but I get nothing from Register.PORTC (assuming that is what Register.PORTC does). I don't get some random # or 0 or anything, its like the PutByte(BUMP) line is never executed. But I know its getting executed because if I do a BUMP =3D 48, then a 0 appears in my terminal. > >Maybe I'm going about this all wrong with the Register.PORTC. I thought of a way to do it by reading each of the 8 pins manually, then compiling the bits into a byte, but I know the method I came up with is probably not very efficient at all. > >Thanks! > >-C >http://www.theonespot.com >[Non-text portions of this message have been removed] >--------------------------- ONElist Sponsor ---------------------------- > > Hey Freelancers: Find your next project through JobSwarm! > You can even make money in your sleep by referring friends. ><a href=" http://clickme.onelist.com/ad/jobswarm1 ">Click Here</a> > >------------------------------------------------------------------------ |
|
I don't know where the 3D came from, I didn't put it there. Some kind of email server corruption or something. My sample lines should read: Dim BUMP As Byte BUMP = Register.PORTC Call PutByte(BUMP) I know about the three different PORTC's. Which do I use to read the state of the pins? One of the registers is what sets them as inputs or outputs, so I know its not that one. And the other two, PORTC and PINC I tried but with the same results, nothing. I even tried skipping using the variable and using the command PutByte(Register.PORTC), but that didn't have any effect either. Thanks! -C http://www.theonespot.com ----- Original Message ----- From: Michael Fellinger <> To: <> Sent: Sunday, January 09, 2000 11:02 AM Subject: Re: [BasicX] Reading PortC as a byte > From: "Michael Fellinger" <> > > There are three register. names associated with PortC. Look at the list of > register names in the documentation. Do you want to read the pins? The > direction register? The output values? Gotta have the right name. Also, > the 3D shouldn't be there. > > mwf > ----- Original Message ----- > From: "Chris H." <> > To: <> > Sent: Sunday, January 09, 2000 11:45 AM > Subject: [BasicX] Reading PortC as a byte > > From: "Chris H." <> > > > > What's the best way to read all of portC as a byte? > > > > I tried this, but it didn't work (just the lines that I'm having problems > with): > > > > Dim BUMP As Byte > > BUMP =3D Register.PORTC > > Call PutByte(BUMP) > > > > All the other PutByte statements in the same routine work fine, but I get > nothing from Register.PORTC (assuming that is what Register.PORTC does). I > don't get some random # or 0 or anything, its like the PutByte(BUMP) line is > never executed. But I know its getting executed because if I do a BUMP =3D > 48, then a 0 appears in my terminal. > > > > Maybe I'm going about this all wrong with the Register.PORTC. I thought of > a way to do it by reading each of the 8 pins manually, then compiling the > bits into a byte, but I know the method I came up with is probably not very > efficient at all. > > > > Thanks! > > > > -C > > http://www.theonespot.com > > > > > > [Non-text portions of this message have been removed] > > > > > > --------------------------- ONElist Sponsor ---------------------------- > > > > Hey Freelancers: Find your next project through JobSwarm! > > You can even make money in your sleep by referring friends. > > <a href=" http://clickme.onelist.com/ad/jobswarm1 ">Click Here</a> > > > > ------------------------------------------------------------------------ > > --------------------------- ONElist Sponsor ---------------------------- > > Independent contractors: Find your next project gig through JobSwarm! > You can even make money by referring friends. > <a href=" http://clickme.onelist.com/ad/jobswarm2 ">Click Here</a> > > ------------------------------------------------------------------------ |
|
That is what I'm doing, but it does not work. Niether Register.PORTC or Register.PINC is returning anything as far as I can tell. I want to read the entire port as a byte and then transmit that byte to my PC. To do so, I'm creating a variable as a byte (Public BUMP As Byte), then I make BUMP equel to PORTC (BUMP = Register.PORTC), Then I am trying to send the byte to the PC by using the PutByte command of the serialport.bas file (Call PutByte(BUMP)). But nothing is being sent out the serial port for just that one PutByte command, all the other PutByte and PutL calls in the same sub routine are working fine. I mean nothing. Not some random value, a 0, or anything, its like the entire PutByte command is not being executed. Here is the entire code I'm working on. I'm basically reading all the ADC channels and all of port c and then sending the values out the serial port with some header and seperator chacters. Everything is being sent fine except the PutByte(BUMP). ---- Code Start ---- Public ADC1 As Integer 'Pin 20 Public ADC2 As Integer 'Pin 19 Public ADC3 As Integer 'Pin 18 Public ADC4 As Integer 'Pin 17 Public ADC5 As Integer 'Pin 16 Public ADC6 As Integer 'Pin 15 Public ADC7 As Integer 'Pin 14 Public ADC8 As Integer 'Pin 13 Public BUMP As Byte ' Const GreenLED As Byte = 26 ' Const RedLED As Byte = 25 ' Const LEDon As Byte = 0 ' Const LEDoff As Byte = 1 Sub Main() Call OpenSerialPort(1, 19200) Call Delay(0.5) Do ' Read 8 bump switches directly using the PORTC (or PINC) register and put into public variable BUMP = Register.PORTC ' Read 8 ADC ports and put values into public variables ADC1 = GetADC(20) ADC2 = GetADC(19) ADC3 = GetADC(18) ADC4 = GetADC(17) ADC5 = GetADC(16) ADC6 = GetADC(15) ADC7 = GetADC(14) ADC8 = GetADC(13) ' Send data out serial port to PC, starting with three bytes of 170. Call PutByte(170) Call PutByte(170) Call PutByte(170) Call Delay(0.1) Call PutByte(BUMP) Call Delay(0.1) Call PutByte(33) Call Delay(0.1) Call PutI(ADC1) Call Delay(0.1) Call PutByte(33) Call PutI(ADC2) Call Delay(0.1) Call PutByte(33) Call PutI(ADC3) Call Delay(0.1) Call PutByte(33) Call PutI(ADC4) Call Delay(0.1) Call PutByte(33) Call PutI(ADC5) Call Delay(0.1) Call PutByte(33) Call PutI(ADC6) Call Delay(0.1) Call PutByte(33) Call PutI(ADC7) Call Delay(0.1) Call PutByte(33) Call PutI(ADC8) Call Delay(0.1) Call PutByte(35) 'End of string byte Loop End Sub ---- Code End ---- |
|
I see two things wrong, First, I don't see where you setup your data direction register for portC. The DDR (data direction register) tells the chip what your going to do with that port (i.e.read or write to it) so without setting the DDR you will get nothing. Second, your trying to read portc with the write command. PinC will read the port while PortC will write to it. I've added the needed code for you. Chris ---------- From: Chris H. [SMTP:] Sent: Sunday, January 09, 2000 1:33 PM To: Subject: Re: [BasicX] Reading PortC as a byte From: "Chris H." <> That is what I'm doing, but it does not work. Niether Register.PORTC or Register.PINC is returning anything as far as I can tell. I want to read the entire port as a byte and then transmit that byte to my PC. To do so, I'm creating a variable as a byte (Public BUMP As Byte), then I make BUMP equel to PORTC (BUMP = Register.PORTC), Then I am trying to send the byte to the PC by using the PutByte command of the serialport.bas file (Call PutByte(BUMP)). But nothing is being sent out the serial port for just that one PutByte command, all the other PutByte and PutL calls in the same sub routine are working fine. I mean nothing. Not some random value, a 0, or anything, its like the entire PutByte command is not being executed. Here is the entire code I'm working on. I'm basically reading all the ADC channels and all of port c and then sending the values out the serial port with some header and seperator chacters. Everything is being sent fine except the PutByte(BUMP). ---- Code Start ---- Public ADC1 As Integer 'Pin 20 Public ADC2 As Integer 'Pin 19 Public ADC3 As Integer 'Pin 18 Public ADC4 As Integer 'Pin 17 Public ADC5 As Integer 'Pin 16 Public ADC6 As Integer 'Pin 15 Public ADC7 As Integer 'Pin 14 Public ADC8 As Integer 'Pin 13 Public BUMP As Byte ' Const GreenLED As Byte = 26 ' Const RedLED As Byte = 25 ' Const LEDon As Byte = 0 ' Const LEDoff As Byte = 1 Sub Main() Call OpenSerialPort(1, 19200) Call Delay(0.5) ' Make portC an input ******************* Register.DDRC = &h00 Do ' Read 8 bump switches directly using the PORTC (or PINC) register and put into public variable BUMP = Register.PINC ' Read 8 ADC ports and put values into public variables ADC1 = GetADC(20) ADC2 = GetADC(19) ADC3 = GetADC(18) ADC4 = GetADC(17) ADC5 = GetADC(16) ADC6 = GetADC(15) ADC7 = GetADC(14) ADC8 = GetADC(13) ' Send data out serial port to PC, starting with three bytes of 170. Call PutByte(170) Call PutByte(170) Call PutByte(170) Call Delay(0.1) Call PutByte(BUMP) Call Delay(0.1) Call PutByte(33) Call Delay(0.1) Call PutI(ADC1) Call Delay(0.1) Call PutByte(33) Call PutI(ADC2) Call Delay(0.1) Call PutByte(33) Call PutI(ADC3) Call Delay(0.1) Call PutByte(33) Call PutI(ADC4) Call Delay(0.1) Call PutByte(33) Call PutI(ADC5) Call Delay(0.1) Call PutByte(33) Call PutI(ADC6) Call Delay(0.1) Call PutByte(33) Call PutI(ADC7) Call Delay(0.1) Call PutByte(33) Call PutI(ADC8) Call Delay(0.1) Call PutByte(35) 'End of string byte Loop End Sub ---- Code End ---- --------------------------- ONElist Sponsor ---------------------------- Independent contractors: Find your next project gig through JobSwarm! You can even make money by referring friends. <a href=" http://clickme.onelist.com/ad/jobswarm2 ">Click Here</a ------------------------------------------------------------------------ |
|
Have you tried this code since I modified it? Chris ---------- From: Chris Harriman [SMTP:] Sent: Sunday, January 09, 2000 3:13 PM To: ' Subject: RE: [BasicX] Reading PortC as a byte From: Chris Harriman < <mailto:> I see two things wrong, First, I don't see where you setup your data direction register for portC. The DDR (data direction register) tells the chip what your going to do with that port (i.e.read or write to it) so without setting the DDR you will get nothing. Second, your trying to read portc with the write command. PinC will read the port while PortC will write to it. I've added the needed code for you. Chris ---------- From: Chris H. [SMTP:] <mailto:[SMTP:]> Sent: Sunday, January 09, 2000 1:33 PM To: <mailto:> Subject: Re: [BasicX] Reading PortC as a byte From: "Chris H." < <mailto:> > That is what I'm doing, but it does not work. Niether Register.PORTC or Register.PINC is returning anything as far as I can tell. I want to read the entire port as a byte and then transmit that byte to my PC. To do so, I'm creating a variable as a byte (Public BUMP As Byte), then I make BUMP equel to PORTC (BUMP = Register.PORTC), Then I am trying to send the byte to the PC by using the PutByte command of the serialport.bas file (Call PutByte(BUMP)). But nothing is being sent out the serial port for just that one PutByte command, all the other PutByte and PutL calls in the same sub routine are working fine. I mean nothing. Not some random value, a 0, or anything, its like the entire PutByte command is not being executed. Here is the entire code I'm working on. I'm basically reading all the ADC channels and all of port c and then sending the values out the serial port with some header and seperator chacters. Everything is being sent fine except the PutByte(BUMP). ---- Code Start ---- Public ADC1 As Integer 'Pin 20 Public ADC2 As Integer 'Pin 19 Public ADC3 As Integer 'Pin 18 Public ADC4 As Integer 'Pin 17 Public ADC5 As Integer 'Pin 16 Public ADC6 As Integer 'Pin 15 Public ADC7 As Integer 'Pin 14 Public ADC8 As Integer 'Pin 13 Public BUMP As Byte ' Const GreenLED As Byte = 26 ' Const RedLED As Byte = 25 ' Const LEDon As Byte = 0 ' Const LEDoff As Byte = 1 Sub Main() Call OpenSerialPort(1, 19200) Call Delay(0.5) ' Make portC an input ******************* Register.DDRC = &h00 Do ' Read 8 bump switches directly using the PORTC (or PINC) register and put into public variable '* Changed to read portc********************** BUMP = Register.PINC ' Read 8 ADC ports and put values into public variables ADC1 = GetADC(20) ADC2 = GetADC(19) ADC3 = GetADC(18) ADC4 = GetADC(17) ADC5 = GetADC(16) ADC6 = GetADC(15) ADC7 = GetADC(14) ADC8 = GetADC(13) ' Send data out serial port to PC, starting with three bytes of 170. Call PutByte(170) Call PutByte(170) Call PutByte(170) Call Delay(0.1) Call PutByte(BUMP) Call Delay(0.1) Call PutByte(33) Call Delay(0.1) Call PutI(ADC1) Call Delay(0.1) Call PutByte(33) Call PutI(ADC2) Call Delay(0.1) Call PutByte(33) Call PutI(ADC3) Call Delay(0.1) Call PutByte(33) Call PutI(ADC4) Call Delay(0.1) Call PutByte(33) Call PutI(ADC5) Call Delay(0.1) Call PutByte(33) Call PutI(ADC6) Call Delay(0.1) Call PutByte(33) Call PutI(ADC7) Call Delay(0.1) Call PutByte(33) Call PutI(ADC8) Call Delay(0.1) Call PutByte(35) 'End of string byte Loop End Sub ---- Code End ---- --------------------------- ONElist Sponsor ---------------------------- Independent contractors: Find your next project gig through JobSwarm! You can even make money by referring friends. <a href=" http://clickme.onelist.com/ad/jobswarm2 <http://clickme.onelist.com/ad/jobswarm2> ">Click Here</a ------------------------------------------------------------------------ --------------------------- ONElist Sponsor ---------------------------- Hey Freelancers: Find your next project through JobSwarm! You can even make money in your sleep by referring friends. <a href=" http://clickme.onelist.com/ad/jobswarm1 <http://clickme.onelist.com/ad/jobswarm1> ">Click Here</a ------------------------------------------------------------------------ |
|
That didn't work either, still nothing. :( I thought that the chip window in the editor did all the setting up of what pin does what (as far as input, output, intial output state, etc). If not, what does the chip window do? -C http://www.theonespot.com ----- Original Message ----- From: Chris Harriman <> To: <> Sent: Sunday, January 09, 2000 2:41 PM Subject: RE: [BasicX] Reading PortC as a byte > From: Chris Harriman <> > > Have you tried this code since I modified it? > > Chris > > ---------- > From: Chris Harriman [SMTP:] > Sent: Sunday, January 09, 2000 3:13 PM > To: ' > Subject: RE: [BasicX] Reading PortC as a byte > > From: Chris Harriman < > <mailto:> > I see two things wrong, > First, I don't see where you setup your data direction register for > portC. > The DDR > (data direction register) tells the chip what your going to do with > that port (i.e.read or write to it) so without setting the DDR you will get > nothing. > Second, your trying to read portc with the write command. PinC will > read the port while PortC will write to it. > I've added the needed code for you. > Chris > > ---------- > From: Chris H. [SMTP:] > <mailto:[SMTP:]> > Sent: Sunday, January 09, 2000 1:33 PM > To: <mailto:> > Subject: Re: [BasicX] Reading PortC as a byte > From: "Chris H." < > <mailto:> > > > That is what I'm doing, but it does not work. Niether Register.PORTC > or > Register.PINC is returning anything as far as I can tell. I want to > read the > entire port as a byte and then transmit that byte to my PC. To do > so, I'm > creating a variable as a byte (Public BUMP As Byte), then I make > BUMP equel > to PORTC (BUMP = Register.PORTC), Then I am trying to send the byte > to the > PC by using the PutByte command of the serialport.bas file (Call > PutByte(BUMP)). But nothing is being sent out the serial port for > just that > one PutByte command, all the other PutByte and PutL calls in the > same sub > routine are working fine. I mean nothing. Not some random value, a > 0, or > anything, its like the entire PutByte command is not being executed. > Here is the entire code I'm working on. I'm basically reading all > the ADC > channels and all of port c and then sending the values out the > serial port > with some header and seperator chacters. Everything is being sent > fine > except the PutByte(BUMP). > ---- Code Start ---- > Public ADC1 As Integer 'Pin 20 > Public ADC2 As Integer 'Pin 19 > Public ADC3 As Integer 'Pin 18 > Public ADC4 As Integer 'Pin 17 > Public ADC5 As Integer 'Pin 16 > Public ADC6 As Integer 'Pin 15 > Public ADC7 As Integer 'Pin 14 > Public ADC8 As Integer 'Pin 13 > > Public BUMP As Byte > ' Const GreenLED As Byte = 26 > ' Const RedLED As Byte = 25 > ' Const LEDon As Byte = 0 > ' Const LEDoff As Byte = 1 > > Sub Main() > Call OpenSerialPort(1, 19200) > Call Delay(0.5) > > ' Make portC an input ******************* > Register.DDRC = &h00 > > Do > ' Read 8 bump switches directly using the PORTC (or > PINC) register > and put > into public variable > > '* Changed to read portc********************** > BUMP = Register.PINC > ' Read 8 ADC ports and put values into public variables > ADC1 = GetADC(20) > ADC2 = GetADC(19) > ADC3 = GetADC(18) > ADC4 = GetADC(17) > ADC5 = GetADC(16) > ADC6 = GetADC(15) > ADC7 = GetADC(14) > ADC8 = GetADC(13) > > ' Send data out serial port to PC, starting with three bytes of 170. > Call PutByte(170) > Call PutByte(170) > Call PutByte(170) > Call Delay(0.1) > Call PutByte(BUMP) > Call Delay(0.1) > Call PutByte(33) > Call Delay(0.1) > Call PutI(ADC1) > Call Delay(0.1) > Call PutByte(33) > Call PutI(ADC2) > Call Delay(0.1) > Call PutByte(33) > Call PutI(ADC3) > Call Delay(0.1) > Call PutByte(33) > Call PutI(ADC4) > Call Delay(0.1) > Call PutByte(33) > Call PutI(ADC5) > Call Delay(0.1) > Call PutByte(33) > Call PutI(ADC6) > Call Delay(0.1) > Call PutByte(33) > Call PutI(ADC7) > Call Delay(0.1) > Call PutByte(33) > Call PutI(ADC8) > Call Delay(0.1) > Call PutByte(35) 'End of string byte > Loop > > End Sub > ---- Code End ---- > > --------------------------- ONElist Sponsor > ---------------------------- > > Independent contractors: Find your next project gig through > JobSwarm! > You can even make money by referring friends. > <a href=" http://clickme.onelist.com/ad/jobswarm2 > <http://clickme.onelist.com/ad/jobswarm2> ">Click Here</a > ------------------------------------------------------------------------ > > --------------------------- ONElist Sponsor > ---------------------------- > Hey Freelancers: Find your next project through JobSwarm! > You can even make money in your sleep by referring friends. > <a href=" http://clickme.onelist.com/ad/jobswarm1 > <http://clickme.onelist.com/ad/jobswarm1> ">Click Here</a > ------------------------------------------------------------------------ > > --------------------------- ONElist Sponsor ---------------------------- > > Independent contractors: Find your next project gig through JobSwarm! > You can even make money by referring friends. > <a href=" http://clickme.onelist.com/ad/jobswarm2 ">Click Here</a> > > ------------------------------------------------------------------------ |
|
If you are trying to use the internal pullups on the pins, then you must do the following: register.ddrc = 0 'makes all inputs register.portc = &HFF 'makes all have pullups 'then you can read the switches switches = register.pinc Jack -----Original Message----- From: Chris H. <> To: <> Date: Sunday, January 09, 2000 3:49 PM Subject: Re: [BasicX] Reading PortC as a byte >From: "Chris H." <> > >That didn't work either, still nothing. :( > >I thought that the chip window in the editor did all the setting up of what >pin does what (as far as input, output, intial output state, etc). If not, >what does the chip window do? > >-C >http://www.theonespot.com > >----- Original Message ----- >From: Chris Harriman <> >To: <> >Sent: Sunday, January 09, 2000 2:41 PM >Subject: RE: [BasicX] Reading PortC as a byte >> From: Chris Harriman <> >> >> Have you tried this code since I modified it? >> >> Chris >> >> ---------- >> From: Chris Harriman [SMTP:] >> Sent: Sunday, January 09, 2000 3:13 PM >> To: ' >> Subject: RE: [BasicX] Reading PortC as a byte >> >> From: Chris Harriman < >> <mailto:> > >> >> >> I see two things wrong, >> First, I don't see where you setup your data direction register for >> portC. >> The DDR >> (data direction register) tells the chip what your going to do with >> that port (i.e.read or write to it) so without setting the DDR you will >get >> nothing. >> Second, your trying to read portc with the write command. PinC will >> read the port while PortC will write to it. >> I've added the needed code for you. >> Chris >> >> ---------- >> From: Chris H. [SMTP:] >> <mailto:[SMTP:]> >> Sent: Sunday, January 09, 2000 1:33 PM >> To: <mailto:> >> Subject: Re: [BasicX] Reading PortC as a byte >> From: "Chris H." < >> <mailto:> > >> >> That is what I'm doing, but it does not work. Niether Register.PORTC >> or >> Register.PINC is returning anything as far as I can tell. I want to >> read the >> entire port as a byte and then transmit that byte to my PC. To do >> so, I'm >> creating a variable as a byte (Public BUMP As Byte), then I make >> BUMP equel >> to PORTC (BUMP = Register.PORTC), Then I am trying to send the byte >> to the >> PC by using the PutByte command of the serialport.bas file (Call >> PutByte(BUMP)). But nothing is being sent out the serial port for >> just that >> one PutByte command, all the other PutByte and PutL calls in the >> same sub >> routine are working fine. I mean nothing. Not some random value, a >> 0, or >> anything, its like the entire PutByte command is not being executed. >> Here is the entire code I'm working on. I'm basically reading all >> the ADC >> channels and all of port c and then sending the values out the >> serial port >> with some header and seperator chacters. Everything is being sent >> fine >> except the PutByte(BUMP). >> ---- Code Start ---- >> Public ADC1 As Integer 'Pin 20 >> Public ADC2 As Integer 'Pin 19 >> Public ADC3 As Integer 'Pin 18 >> Public ADC4 As Integer 'Pin 17 >> Public ADC5 As Integer 'Pin 16 >> Public ADC6 As Integer 'Pin 15 >> Public ADC7 As Integer 'Pin 14 >> Public ADC8 As Integer 'Pin 13 >> >> Public BUMP As Byte >> ' Const GreenLED As Byte = 26 >> ' Const RedLED As Byte = 25 >> ' Const LEDon As Byte = 0 >> ' Const LEDoff As Byte = 1 >> >> Sub Main() >> Call OpenSerialPort(1, 19200) >> Call Delay(0.5) >> >> ' Make portC an input ******************* >> Register.DDRC = &h00 >> >> Do >> ' Read 8 bump switches directly using the PORTC (or >> PINC) register >> and put >> into public variable >> >> '* Changed to read portc********************** >> BUMP = Register.PINC >> ' Read 8 ADC ports and put values into public variables >> ADC1 = GetADC(20) >> ADC2 = GetADC(19) >> ADC3 = GetADC(18) >> ADC4 = GetADC(17) >> ADC5 = GetADC(16) >> ADC6 = GetADC(15) >> ADC7 = GetADC(14) >> ADC8 = GetADC(13) >> >> ' Send data out serial port to PC, starting with three bytes of 170. >> Call PutByte(170) >> Call PutByte(170) >> Call PutByte(170) >> Call Delay(0.1) >> Call PutByte(BUMP) >> Call Delay(0.1) >> Call PutByte(33) >> Call Delay(0.1) >> Call PutI(ADC1) >> Call Delay(0.1) >> Call PutByte(33) >> Call PutI(ADC2) >> Call Delay(0.1) >> Call PutByte(33) >> Call PutI(ADC3) >> Call Delay(0.1) >> Call PutByte(33) >> Call PutI(ADC4) >> Call Delay(0.1) >> Call PutByte(33) >> Call PutI(ADC5) >> Call Delay(0.1) >> Call PutByte(33) >> Call PutI(ADC6) >> Call Delay(0.1) >> Call PutByte(33) >> Call PutI(ADC7) >> Call Delay(0.1) >> Call PutByte(33) >> Call PutI(ADC8) >> Call Delay(0.1) >> Call PutByte(35) 'End of string byte >> Loop >> >> End Sub >> ---- Code End ---- >> >> --------------------------- ONElist Sponsor >> ---------------------------- >> >> Independent contractors: Find your next project gig through >> JobSwarm! >> You can even make money by referring friends. >> <a href=" http://clickme.onelist.com/ad/jobswarm2 >> <http://clickme.onelist.com/ad/jobswarm2> ">Click Here</a> >> >> >> ------------------------------------------------------------------------ >> >> --------------------------- ONElist Sponsor >> ---------------------------- >> Hey Freelancers: Find your next project through JobSwarm! >> You can even make money in your sleep by referring friends. >> <a href=" http://clickme.onelist.com/ad/jobswarm1 >> <http://clickme.onelist.com/ad/jobswarm1> ">Click Here</a> >> >> >> ------------------------------------------------------------------------ >> >> --------------------------- ONElist Sponsor ---------------------------- >> >> Independent contractors: Find your next project gig through JobSwarm! >> You can even make money by referring friends. >> <a href=" http://clickme.onelist.com/ad/jobswarm2 ">Click Here</a> >> >> ------------------------------------------------------------------------ > >--------------------------- ONElist Sponsor ---------------------------- > >Independent contractors: Find your next project gig through JobSwarm! > You can even make money by referring friends. ><a href=" http://clickme.onelist.com/ad/jobswarm2 ">Click Here</a> > >------------------------------------------------------------------------ |
|
That didn't work either. I tried both standard and pullup inputs. Still get nothing. I have all of portc pins tied to ground (pins 5 through 12). I don't have the yellow dot MCU, would that make a difference? -C http://www.theonespot.com ----- Original Message ----- From: Jack Schoof <> To: <> Sent: Sunday, January 09, 2000 7:44 PM Subject: Re: [BasicX] Reading PortC as a byte > From: "Jack Schoof" <> > > If you are trying to use the internal pullups on the pins, then you must do > the following: > > register.ddrc = 0 'makes all inputs > register.portc = &HFF 'makes all have pullups > > 'then you can read the switches > > switches = register.pinc > > Jack > > -----Original Message----- > From: Chris H. <> > To: <> > Date: Sunday, January 09, 2000 3:49 PM > Subject: Re: [BasicX] Reading PortC as a byte > >From: "Chris H." <> > > > >That didn't work either, still nothing. :( > > > >I thought that the chip window in the editor did all the setting up of what > >pin does what (as far as input, output, intial output state, etc). If not, > >what does the chip window do? > > > >-C > >http://www.theonespot.com > > > >----- Original Message ----- > >From: Chris Harriman <> > >To: <> > >Sent: Sunday, January 09, 2000 2:41 PM > >Subject: RE: [BasicX] Reading PortC as a byte > > > > > >> From: Chris Harriman <> > >> > >> Have you tried this code since I modified it? > >> > >> Chris > >> > >> ---------- > >> From: Chris Harriman < > >> <mailto:> > > >> > >> > >> I see two things wrong, > >> First, I don't see where you setup your data direction register for > >> portC. > >> The DDR > >> (data direction register) tells the chip what your going to do with > >> that port (i.e.read or write to it) so without setting the DDR you will > >get > >> nothing. > >> Second, your trying to read portc with the write command. PinC will > >> read the port while PortC will write to it. > >> I've added the needed code for you. > >> Chris > >> > >> ---------- > >> Sent: Sunday, January 09, 2000 1:33 PM > >> Subject: Re: [BasicX] Reading PortC as a byte > >> From: "Chris H." < > >> > >> That is what I'm doing, but it does not work. Niether Register.PORTC > >> or > >> Register.PINC is returning anything as far as I can tell. I want to > >> read the > >> entire port as a byte and then transmit that byte to my PC. To do > >> so, I'm > >> creating a variable as a byte (Public BUMP As Byte), then I make > >> BUMP equel > >> to PORTC (BUMP = Register.PORTC), Then I am trying to send the byte > >> to the > >> PC by using the PutByte command of the serialport.bas file (Call > >> PutByte(BUMP)). But nothing is being sent out the serial port for > >> just that > >> one PutByte command, all the other PutByte and PutL calls in the > >> same sub > >> routine are working fine. I mean nothing. Not some random value, a > >> 0, or > >> anything, its like the entire PutByte command is not being executed. > >> Here is the entire code I'm working on. I'm basically reading all > >> the ADC > >> channels and all of port c and then sending the values out the > >> serial port > >> with some header and seperator chacters. Everything is being sent > >> fine > >> except the PutByte(BUMP). > >> ---- Code Start ---- > >> Public ADC1 As Integer 'Pin 20 > >> Public ADC2 As Integer 'Pin 19 > >> Public ADC3 As Integer 'Pin 18 > >> Public ADC4 As Integer 'Pin 17 > >> Public ADC5 As Integer 'Pin 16 > >> Public ADC6 As Integer 'Pin 15 > >> Public ADC7 As Integer 'Pin 14 > >> Public ADC8 As Integer 'Pin 13 > >> > >> Public BUMP As Byte > >> ' Const GreenLED As Byte = 26 > >> ' Const RedLED As Byte = 25 > >> ' Const LEDon As Byte = 0 > >> ' Const LEDoff As Byte = 1 > >> > >> Sub Main() > >> Call OpenSerialPort(1, 19200) > >> Call Delay(0.5) > >> > >> ' Make portC an input ******************* > >> Register.DDRC = &h00 > >> > >> Do > >> ' Read 8 bump switches directly using the PORTC (or > >> PINC) register > >> and put > >> into public variable > >> > >> '* Changed to read portc********************** > >> BUMP = Register.PINC > >> ' Read 8 ADC ports and put values into public variables > >> ADC1 = GetADC(20) > >> ADC2 = GetADC(19) > >> ADC3 = GetADC(18) > >> ADC4 = GetADC(17) > >> ADC5 = GetADC(16) > >> ADC6 = GetADC(15) > >> ADC7 = GetADC(14) > >> ADC8 = GetADC(13) > >> > >> ' Send data out serial port to PC, starting with three bytes of 170. > >> Call PutByte(170) > >> Call PutByte(170) > >> Call PutByte(170) > >> Call Delay(0.1) > >> Call PutByte(BUMP) > >> Call Delay(0.1) > >> Call PutByte(33) > >> Call Delay(0.1) > >> Call PutI(ADC1) > >> Call Delay(0.1) > >> Call PutByte(33) > >> Call PutI(ADC2) > >> Call Delay(0.1) > >> Call PutByte(33) > >> Call PutI(ADC3) > >> Call Delay(0.1) > >> Call PutByte(33) > >> Call PutI(ADC4) > >> Call Delay(0.1) > >> Call PutByte(33) > >> Call PutI(ADC5) > >> Call Delay(0.1) > >> Call PutByte(33) > >> Call PutI(ADC6) > >> Call Delay(0.1) > >> Call PutByte(33) > >> Call PutI(ADC7) > >> Call Delay(0.1) > >> Call PutByte(33) > >> Call PutI(ADC8) > >> Call Delay(0.1) > >> Call PutByte(35) 'End of string byte > >> Loop > >> > >> End Sub > >> ---- Code End ---- |
|
If they are all tied to ground, how do you expect to get any data from them? Can you please send me a schematic (even an ascii one) of a single pin. Jack -----Original Message----- From: Chris H. <> To: <> Date: Sunday, January 09, 2000 9:16 PM Subject: Re: [BasicX] Reading PortC as a byte >From: "Chris H." <> > >That didn't work either. I tried both standard and pullup inputs. Still get >nothing. I have all of portc pins tied to ground (pins 5 through 12). > >I don't have the yellow dot MCU, would that make a difference? > >-C >http://www.theonespot.com >----- Original Message ----- >From: Jack Schoof <> >To: <> >Sent: Sunday, January 09, 2000 7:44 PM >Subject: Re: [BasicX] Reading PortC as a byte >> From: "Jack Schoof" <> >> >> If you are trying to use the internal pullups on the pins, then you must >do >> the following: >> >> register.ddrc = 0 'makes all inputs >> register.portc = &HFF 'makes all have pullups >> >> 'then you can read the switches >> >> switches = register.pinc >> >> Jack >> >> -----Original Message----- >> From: Chris H. <> >> To: <> >> Date: Sunday, January 09, 2000 3:49 PM >> Subject: Re: [BasicX] Reading PortC as a byte >> >> >> >From: "Chris H." <> >> > >> >That didn't work either, still nothing. :( >> > >> >I thought that the chip window in the editor did all the setting up of >what >> >pin does what (as far as input, output, intial output state, etc). If >not, >> >what does the chip window do? >> > >> >-C >> >http://www.theonespot.com >> > >> >----- Original Message ----- >> >From: Chris Harriman <> >> >To: <> >> >Sent: Sunday, January 09, 2000 2:41 PM >> >Subject: RE: [BasicX] Reading PortC as a byte >> > >> > >> >> From: Chris Harriman <> >> >> >> >> Have you tried this code since I modified it? >> >> >> >> Chris >> >> >> >> ---------- >> >> From: Chris Harriman < >> >> <mailto:> > >> >> >> >> >> >> I see two things wrong, >> >> First, I don't see where you setup your data direction register for >> >> portC. >> >> The DDR >> >> (data direction register) tells the chip what your going to do with >> >> that port (i.e.read or write to it) so without setting the DDR you will >> >get >> >> nothing. >> >> Second, your trying to read portc with the write command. PinC will >> >> read the port while PortC will write to it. >> >> I've added the needed code for you. >> >> Chris >> >> >> >> ---------- >> >> Sent: Sunday, January 09, 2000 1:33 PM >> >> Subject: Re: [BasicX] Reading PortC as a byte >> >> From: "Chris H." < >> >> >> >> That is what I'm doing, but it does not work. Niether Register.PORTC >> >> or >> >> Register.PINC is returning anything as far as I can tell. I want to >> >> read the >> >> entire port as a byte and then transmit that byte to my PC. To do >> >> so, I'm >> >> creating a variable as a byte (Public BUMP As Byte), then I make >> >> BUMP equel >> >> to PORTC (BUMP = Register.PORTC), Then I am trying to send the byte >> >> to the >> >> PC by using the PutByte command of the serialport.bas file (Call >> >> PutByte(BUMP)). But nothing is being sent out the serial port for >> >> just that >> >> one PutByte command, all the other PutByte and PutL calls in the >> >> same sub >> >> routine are working fine. I mean nothing. Not some random value, a >> >> 0, or >> >> anything, its like the entire PutByte command is not being executed. >> >> Here is the entire code I'm working on. I'm basically reading all >> >> the ADC >> >> channels and all of port c and then sending the values out the >> >> serial port >> >> with some header and seperator chacters. Everything is being sent >> >> fine >> >> except the PutByte(BUMP). >> >> ---- Code Start ---- >> >> Public ADC1 As Integer 'Pin 20 >> >> Public ADC2 As Integer 'Pin 19 >> >> Public ADC3 As Integer 'Pin 18 >> >> Public ADC4 As Integer 'Pin 17 >> >> Public ADC5 As Integer 'Pin 16 >> >> Public ADC6 As Integer 'Pin 15 >> >> Public ADC7 As Integer 'Pin 14 >> >> Public ADC8 As Integer 'Pin 13 >> >> >> >> Public BUMP As Byte >> >> ' Const GreenLED As Byte = 26 >> >> ' Const RedLED As Byte = 25 >> >> ' Const LEDon As Byte = 0 >> >> ' Const LEDoff As Byte = 1 >> >> >> >> Sub Main() >> >> Call OpenSerialPort(1, 19200) >> >> Call Delay(0.5) >> >> >> >> ' Make portC an input ******************* >> >> Register.DDRC = &h00 >> >> >> >> Do >> >> ' Read 8 bump switches directly using the PORTC (or >> >> PINC) register >> >> and put >> >> into public variable >> >> >> >> '* Changed to read portc********************** >> >> BUMP = Register.PINC >> >> ' Read 8 ADC ports and put values into public variables >> >> ADC1 = GetADC(20) >> >> ADC2 = GetADC(19) >> >> ADC3 = GetADC(18) >> >> ADC4 = GetADC(17) >> >> ADC5 = GetADC(16) >> >> ADC6 = GetADC(15) >> >> ADC7 = GetADC(14) >> >> ADC8 = GetADC(13) >> >> >> >> ' Send data out serial port to PC, starting with three bytes of 170. >> >> Call PutByte(170) >> >> Call PutByte(170) >> >> Call PutByte(170) >> >> Call Delay(0.1) >> >> Call PutByte(BUMP) >> >> Call Delay(0.1) >> >> Call PutByte(33) >> >> Call Delay(0.1) >> >> Call PutI(ADC1) >> >> Call Delay(0.1) >> >> Call PutByte(33) >> >> Call PutI(ADC2) >> >> Call Delay(0.1) >> >> Call PutByte(33) >> >> Call PutI(ADC3) >> >> Call Delay(0.1) >> >> Call PutByte(33) >> >> Call PutI(ADC4) >> >> Call Delay(0.1) >> >> Call PutByte(33) >> >> Call PutI(ADC5) >> >> Call Delay(0.1) >> >> Call PutByte(33) >> >> Call PutI(ADC6) >> >> Call Delay(0.1) >> >> Call PutByte(33) >> >> Call PutI(ADC7) >> >> Call Delay(0.1) >> >> Call PutByte(33) >> >> Call PutI(ADC8) >> >> Call Delay(0.1) >> >> Call PutByte(35) 'End of string byte >> >> Loop >> >> >> >> End Sub >> >> ---- Code End ---- >--------------------------- ONElist Sponsor ---------------------------- > > Hey Freelancers: Find your next project through JobSwarm! > You can even make money in your sleep by referring friends. ><a href=" http://clickme.onelist.com/ad/jobswarm1 ">Click Here</a> > >------------------------------------------------------------------------ |
|
All 8 pins of portc are tied directly to ground. Shouldn't I get a reading of zero? This should *simulate* all 8 of my robots bump switches being in the same state. The BX24 is not in its final application, its on my experimenting board at the moment. I was getting the same results when the pins were connected to nothing (just floating). I connected each pin indivdually to ground (same ground is connected to pin 23) to see if maybe my problems were because the pins were not connected to anything, but even with them tied to ground, I still get nothing. Not some random #, not 0, not 255, nothing. Its like the PutByte(BUMP) line is not even being executed. Check my webcam out at http://theone.dynip.com:82 to see a live picture of my setup (refresh for new image). The bottom row of the breadboard is all ground. Yuo can see the 8 green and white wires connected from the breadboards ground over to the BX24's portc. The red wire connects the same breadboard ground, to the BX24's pin 23 so that they share a common ground. Thanks for helping me with this! I'm planning on using 1 BX-24 for all my input needs on my robot (running an onboard PC for its brains). I'll use 1 or 2 more BX24's for more input and for all output. I'm just working on the software for them now while I'm still building the robot (Lazlo robot on my site). -C http://www.theonespot.com ----- Original Message ----- From: Jack Schoof <> To: <> Sent: Sunday, January 09, 2000 8:31 PM Subject: Re: [BasicX] Reading PortC as a byte > From: "Jack Schoof" <> > > If they are all tied to ground, how do you expect to get any data from them? > Can you please send me a schematic (even an ascii one) of a single pin. > > Jack > > -----Original Message----- > From: Chris H. <> > To: <> > Date: Sunday, January 09, 2000 9:16 PM > Subject: Re: [BasicX] Reading PortC as a byte > >From: "Chris H." <> > > > >That didn't work either. I tried both standard and pullup inputs. Still get > >nothing. I have all of portc pins tied to ground (pins 5 through 12). > > > >I don't have the yellow dot MCU, would that make a difference? > > > >-C > >http://www.theonespot.com > > > > > >----- Original Message ----- > >From: Jack Schoof <> > >To: <> > >Sent: Sunday, January 09, 2000 7:44 PM > >Subject: Re: [BasicX] Reading PortC as a byte > > > > > >> From: "Jack Schoof" <> > >> > >> If you are trying to use the internal pullups on the pins, then you must > >do > >> the following: > >> > >> register.ddrc = 0 'makes all inputs > >> register.portc = &HFF 'makes all have pullups > >> > >> 'then you can read the switches > >> > >> switches = register.pinc > >> > >> Jack > >> > >> -----Original Message----- > >> From: Chris H. <> > >> To: <> > >> Date: Sunday, January 09, 2000 3:49 PM > >> Subject: Re: [BasicX] Reading PortC as a byte > >> > >> > >> >From: "Chris H." <> > >> > > >> >That didn't work either, still nothing. :( > >> > > >> >I thought that the chip window in the editor did all the setting up of > >what > >> >pin does what (as far as input, output, intial output state, etc). If > >not, > >> >what does the chip window do? > >> > > >> >-C > >> >http://www.theonespot.com > >> > > >> >----- Original Message ----- > >> >From: Chris Harriman <> > >> >To: <> > >> >Sent: Sunday, January 09, 2000 2:41 PM > >> >Subject: RE: [BasicX] Reading PortC as a byte > >> > > >> > > >> >> From: Chris Harriman <> > >> >> > >> >> Have you tried this code since I modified it? > >> >> > >> >> Chris > >> >> > >> >> ---------- > >> >> From: Chris Harriman < > >> >> <mailto:> > > >> >> > >> >> > >> >> I see two things wrong, > >> >> First, I don't see where you setup your data direction register for > >> >> portC. > >> >> The DDR > >> >> (data direction register) tells the chip what your going to do with > >> >> that port (i.e.read or write to it) so without setting the DDR you > will > >> >get > >> >> nothing. > >> >> Second, your trying to read portc with the write command. PinC will > >> >> read the port while PortC will write to it. > >> >> I've added the needed code for you. > >> >> Chris > >> >> > >> >> ---------- > >> >> Sent: Sunday, January 09, 2000 1:33 PM > >> >> Subject: Re: [BasicX] Reading PortC as a byte > >> >> From: "Chris H." < > >> >> > >> >> That is what I'm doing, but it does not work. Niether Register.PORTC > >> >> or > >> >> Register.PINC is returning anything as far as I can tell. I want to > >> >> read the > >> >> entire port as a byte and then transmit that byte to my PC. To do > >> >> so, I'm > >> >> creating a variable as a byte (Public BUMP As Byte), then I make > >> >> BUMP equel > >> >> to PORTC (BUMP = Register.PORTC), Then I am trying to send the byte > >> >> to the > >> >> PC by using the PutByte command of the serialport.bas file (Call > >> >> PutByte(BUMP)). But nothing is being sent out the serial port for > >> >> just that > >> >> one PutByte command, all the other PutByte and PutL calls in the > >> >> same sub > >> >> routine are working fine. I mean nothing. Not some random value, a > >> >> 0, or > >> >> anything, its like the entire PutByte command is not being executed. > >> >> Here is the entire code I'm working on. I'm basically reading all > >> >> the ADC > >> >> channels and all of port c and then sending the values out the > >> >> serial port > >> >> with some header and seperator chacters. Everything is being sent > >> >> fine > >> >> except the PutByte(BUMP). > >> >> ---- Code Start ---- > >> >> Public ADC1 As Integer 'Pin 20 > >> >> Public ADC2 As Integer 'Pin 19 > >> >> Public ADC3 As Integer 'Pin 18 > >> >> Public ADC4 As Integer 'Pin 17 > >> >> Public ADC5 As Integer 'Pin 16 > >> >> Public ADC6 As Integer 'Pin 15 > >> >> Public ADC7 As Integer 'Pin 14 > >> >> Public ADC8 As Integer 'Pin 13 > >> >> > >> >> Public BUMP As Byte > >> >> ' Const GreenLED As Byte = 26 > >> >> ' Const RedLED As Byte = 25 > >> >> ' Const LEDon As Byte = 0 > >> >> ' Const LEDoff As Byte = 1 > >> >> > >> >> Sub Main() > >> >> Call OpenSerialPort(1, 19200) > >> >> Call Delay(0.5) > >> >> > >> >> ' Make portC an input ******************* > >> >> Register.DDRC = &h00 > >> >> > >> >> Do > >> >> ' Read 8 bump switches directly using the PORTC (or > >> >> PINC) register > >> >> and put > >> >> into public variable > >> >> > >> >> '* Changed to read portc********************** > >> >> BUMP = Register.PINC > >> >> ' Read 8 ADC ports and put values into public variables > >> >> ADC1 = GetADC(20) > >> >> ADC2 = GetADC(19) > >> >> ADC3 = GetADC(18) > >> >> ADC4 = GetADC(17) > >> >> ADC5 = GetADC(16) > >> >> ADC6 = GetADC(15) > >> >> ADC7 = GetADC(14) > >> >> ADC8 = GetADC(13) > >> >> > >> >> ' Send data out serial port to PC, starting with three bytes of 170. > >> >> Call PutByte(170) > >> >> Call PutByte(170) > >> >> Call PutByte(170) > >> >> Call Delay(0.1) > >> >> Call PutByte(BUMP) > >> >> Call Delay(0.1) > >> >> Call PutByte(33) > >> >> Call Delay(0.1) > >> >> Call PutI(ADC1) > >> >> Call Delay(0.1) > >> >> Call PutByte(33) > >> >> Call PutI(ADC2) > >> >> Call Delay(0.1) > >> >> Call PutByte(33) > >> >> Call PutI(ADC3) > >> >> Call Delay(0.1) > >> >> Call PutByte(33) > >> >> Call PutI(ADC4) > >> >> Call Delay(0.1) > >> >> Call PutByte(33) > >> >> Call PutI(ADC5) > >> >> Call Delay(0.1) > >> >> Call PutByte(33) > >> >> Call PutI(ADC6) > >> >> Call Delay(0.1) > >> >> Call PutByte(33) > >> >> Call PutI(ADC7) > >> >> Call Delay(0.1) > >> >> Call PutByte(33) > >> >> Call PutI(ADC8) > >> >> Call Delay(0.1) > >> >> Call PutByte(35) 'End of string byte > >> >> Loop > >> >> > >> >> End Sub > >> >> ---- Code End ---- > > > > > >--------------------------- ONElist Sponsor ---------------------------- > > > > Hey Freelancers: Find your next project through JobSwarm! > > You can even make money in your sleep by referring friends. > ><a href=" http://clickme.onelist.com/ad/jobswarm1 ">Click Here</a> > > > >------------------------------------------------------------------------ > --------------------------- ONElist Sponsor ---------------------------- > > Hey Freelancers: Find your next project through JobSwarm! > You can even make money in your sleep by referring friends. > <a href=" http://clickme.onelist.com/ad/jobswarm1 ">Click Here</a> > > ------------------------------------------------------------------------ |
|
Well, I guess the PINC thing will not work out for me. It doesn't seem to work. Has anyone successfully used the register.pinc command? If so, can you send me your code? If I can't use PINC to read all of port c as a byte, can someone show me another way? I thought of one way by reading each pin individually and then assembling the bits into a byte, but with my skills, I'm pretty sure my method is extremely inefficient and unnecessary. I'm sure there's probably a simple way to do this. Thanks! -C http://www.theonespot.com |
|
Does getpin work? If so PINC must work. try the following substitution for PINC: change register.pinc to rampeek(&H33) This is the RAM location of the PINC pins. Jack -----Original Message----- From: Chris H. <> To: <> Date: Monday, January 10, 2000 2:48 PM Subject: Re: [BasicX] Reading PortC as a byte >From: "Chris H." <> > >Well, I guess the PINC thing will not work out for me. It doesn't seem to >work. Has anyone successfully used the register.pinc command? If so, can you >send me your code? > >If I can't use PINC to read all of port c as a byte, can someone show me >another way? I thought of one way by reading each pin individually and then >assembling the bits into a byte, but with my skills, I'm pretty sure my >method is extremely inefficient and unnecessary. I'm sure there's probably a >simple way to do this. > >Thanks! > >-C >http://www.theonespot.com >--------------------------- ONElist Sponsor ---------------------------- > >Independent contractors: Find your next project gig through JobSwarm! > You can even make money by referring friends. ><a href=" http://clickme.onelist.com/ad/jobswarm2 ">Click Here</a> > >------------------------------------------------------------------------ |