if you want to send 8 bits of data to PORTA in one shot... yes PORTA=MydataToSend will be what you need. Be sure that you have set the TRISA register before that
TRISA=255
if you want to send 8 bits of data to PORTA in one shot... yes PORTA=MydataToSend will be what you need. Be sure that you have set the TRISA register before that
TRISA=255
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Ok, here is my updated code, now I just have a few questions:
1.) Is there a way to split PORTA into analog and digital inputs?
2.) PORTB.4 is the reset clock and basically it has to be pulsing as soon as the microcontroller powers up. The problem is that once i start the other clocks, the time at which the reset goes high has to be in synch with H1 going low and H2 going high. In addition, it's high duration is 1/4 of the high time of the horizontal clocks. I will post up a timing diagram to explain what i mean later today. So basically I can't just put it in one of my loops, I have to start it pulsing at like a 25% duty cycle and when the other clocks are going, it has to be in synch with the horiztonals like i said earlier.
any help is appreciated.
' Connect analog input to (RA0)
' Connect clocks to PORTB
' PORTB.0 is the Vphase1 clock
' PORTB.1 is the Vphase2 clock
' PORTB.2 is the Hphase1 clock
' PORTB.3 is the Hphase2 clock
' PORTB.4 is the reset clock
' Connect pin 2 from the DB9 connector to PORTC.6
' Have a +5V source ready to touch PORTA.2 to trigger clocking process
include "modedefs.bas"
' Define ADCIN parameters
Define ADC_BITS 8 ' Set number of bits in result
DEFINE OSC 20 ' Sets clock speed to 20Mhz
Define ADC_CLOCK 4 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %00000010 ' Set PORTA analog
TRISB = %00000000 ' Set PORTB to all output
Pause 500 ' Wait .5 second
Pause 500 ' Wait .5 second
horizpulse var byte
vertpulse var byte
adval var byte ' Create adval to store result
horizpulse = 1 ' Initialize counters, initial states
vertpulse = 1
PORTB.0 = 0
PORTB.1 = 0
PORTB.2 = 1
PORTB.3 = 0
PORTB.4 = 0
buttonloop:
IF PushButtonOnPORTABIT2 = 1
THEN GOTO vertloop ' Waits for 5V that signals shutter is closed
ELSE GOTO buttonloop
vertloop:
horizpulse = 1
PORTB.0 = 1
PAUSEUS 139
PORTB.0 = 0
PORTB.1 = 1
PAUSEUS 139
PORTB.0 = 1
PORTB.1 = 0
PAUSEUS 139
PORTB.0 = 0
PAUSEUS 270
vertpulse = vertpulse + 1
IF vertpulse < 512
THEN GOTO horizloop
ELSE GOTO buttonloop
horizloop:
PORTB.2 = 0
PORTB.3 = 1
PAUSEUS 139
PORTB.3 = 0
PORTB.2 = 1
PAUSEUS 50
ADCIN 0, adval ' A/D 8 bit value from PORTA.0 into adval
SEROUT2 PORTC.6,16416,[BIN8 adval,13,10] ' Output 8 bit word serially to PC from C.6
PAUSE 87
horizpulse = horizpulse + 1
IF horizpulse < 784
THEN GOTO horizloop
ELSE GOTO vertloop
END
Last edited by TurboLS; - 21st February 2005 at 21:37. Reason: incomplete
for sure... see datasheet in the A/D section.. ADCON1 TABLE 19-21.) Is there a way to split PORTA into analog and digital inputs?
will be interesting to have kind of flowchart and schematic for the other problems you have.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
TurboLS,
What version of PBP are you using? I've never seen this work in any versions I've had.
IF vertpulse < 512
THEN GOTO horizloop
ELSE GOTO buttonloop
I've wanted to use that type of syntax before, but I get nothing but errors. Did I miss an update or something. I have 2.45
Darrel
DT
I am using 2.46 and I will have a pic up soon that has the timing scheme. thanks for the replies.
here is the timing diagram. notice how the reset, H1, and H2 are in synch at the lower right. Also notice that the reset is going all the time, even when the other 4 clocks are not.
please click the link and scroll to page 13
http://www.kodak.com/global/plugins/...2ELongSpec.pdf
thanks.
Last edited by TurboLS; - 21st February 2005 at 22:56.
Oh yeah, i am gettin some errors from that if else stuff too.... gonna have to find a way around that arghhhh!
scratch that, you just have to put all the commands on the same line, like so:
IF vertpulse < 512 THEN GOTO horizloop ELSE GOTO buttonloop
however, i still have 9 errors to fix before mine compiles properly.
Last edited by TurboLS; - 21st February 2005 at 23:13.
Bookmarks