View previous topic :: View next topic |
Author |
Message |
kwsoft
Joined: 23 Jun 2015 Posts: 14
|
Posted: Fri Jul 24, 2015 5:38 pm Post subject: why print is neccessary? |
|
|
I have a function which reads a pin:
Code: |
$baud = 9600 ' use baud rate
Const LICHTSCHRANKE_ZU = 1
Lichtschranke Alias Pinc.2
Config lichtschranke = Input
portc.2 = 1 'Pullup
...
Sub Nullpunkt_Finden()
If Lichtschranke = LICHTSCHRANKE_ZU Then
Debug "Schlitten Vor"
...
|
This function is called at startup after initializing the variables.
If the photo sensor is closed, the If-Statement is NOT called. Do I print or debug anything to serial port before, the code is executed. I'm using an Atmega8 with Hardware-serial-port, without further configuration.
Is it a Bug oder a Feature?
(BASCOM-AVR version : 2.0.7.8 )
Last edited by kwsoft on Sun Jul 26, 2015 10:18 am; edited 1 time in total |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Fri Jul 24, 2015 6:56 pm Post subject: |
|
|
Please write in english, this is an english forum !
or visit the German Bascom Forum _________________ / Kim |
|
Back to top |
|
|
kwsoft
Joined: 23 Jun 2015 Posts: 14
|
Posted: Sun Jul 26, 2015 10:19 am Post subject: |
|
|
It's translated |
|
Back to top |
|
|
Meister
Joined: 27 May 2010 Posts: 319
|
Posted: Sun Jul 26, 2015 10:53 am Post subject: |
|
|
Quote: | If the photo sensor is closed, the If-Statement is NOT called. |
Are there other statements executed between If-Endif?
Is Debug on or off?
If you replace Debug by Print, will it be printed? |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun Jul 26, 2015 5:44 pm Post subject: |
|
|
Hi,
Maybe you Need a short delay after Setting the pin high (portc.2 = 1 ) before reading the pin, and in your case the print Statement delays the code Long enough.
Try replacing the print statement with a waitms 1
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
kwsoft
Joined: 23 Jun 2015 Posts: 14
|
Posted: Mon Jul 27, 2015 7:44 am Post subject: |
|
|
Quote: | Are there other statements executed between If-Endif?
Is Debug on or off? |
The whole code between If and And-If is not executed. It's the same, if I turn off Debug or not. Nessesary is that ther is an output on the serial port.
Quote: | Try replacing the print statement with a waitms 1 |
That's a good idea. I try it this evening. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Mon Jul 27, 2015 8:37 am Post subject: |
|
|
you can best post a more complete piece of your code that will demonstrate the problem.
i can not imagine print has anything to do with it since tx/rx is at different pins. or it must make a short circuit on your board. _________________ Mark |
|
Back to top |
|
|
kwsoft
Joined: 23 Jun 2015 Posts: 14
|
Posted: Wed Jul 29, 2015 10:37 am Post subject: |
|
|
The Idea of Ian Dobson was the right one. The Pin needs a little bit of time to pullup.
Thanks! |
|
Back to top |
|
|
|