Hi,
I posted a question a while back about interfacing a PIC to a 16-bit ADC, after building a programmer and relearning assembly code I've come a long way, but there is one more issue :cry:
First of all, general question(s):
Is a 'bit-test' (btfss) the ONLY way to get a bit from a single port pin?
If PORTB has 7 outputs and 1 input, is it possible to simply move PORTB to W, and then move this stored number to PORTA? Leaving the input from PORTB as an output on PORTA(as well as the 7 outputs from PORTB)?
Secondly, my problem.....
What I am doing is clocking an ADC, and reading the data from it. However, I'm not planning to store any data, I have a subroutine which roughly looks like this...
As you can see, lines 2 and 3 are incorrect, but it shows what I want to do.
Timing is critical, the maximum number of cycles for a sample is 6 or 8.
So thats 3 (or 4) instruction cycles for the clock high, and the same for the clock low. Say the sample would take 8 cycles, just for convienience..
Therefore, 2 cycles of the 8 are used to make the clock high/low, leaving 6 cycles to read the data, send it to output, decrement reg, AND goto SAMPLE. This really is a lot to do in 8 instruction cycles. :shock:
You see, I'm using the PIC16F84A with a 20MHZ clk, giving an instruction period of 200ns. For 8 cycles per sample, = 1.6uS for each bit.
Notes:
The mark/space ratio of the clock is not really important, as long as its above 20ns, (10th of a cycle).
More than 1 bit, cannot be stored, basically, I'm sending the data
out 'on-the-fly'.
The upper limit on the number of instruction cycles for retrieving a bit from the ADC is 8 (inc. subroutine calls, and return, which take 2 cycles)
I really hope someone can provide some alternatives (writing in another language?) because this is the only problem I have with my project, is this is solved, its plain sailing from here on.
Blueteeth, (email: paranoidfoo@hotmail.com)
I posted a question a while back about interfacing a PIC to a 16-bit ADC, after building a programmer and relearning assembly code I've come a long way, but there is one more issue :cry:
First of all, general question(s):
Is a 'bit-test' (btfss) the ONLY way to get a bit from a single port pin?
If PORTB has 7 outputs and 1 input, is it possible to simply move PORTB to W, and then move this stored number to PORTA? Leaving the input from PORTB as an output on PORTA(as well as the 7 outputs from PORTB)?
Secondly, my problem.....
What I am doing is clocking an ADC, and reading the data from it. However, I'm not planning to store any data, I have a subroutine which roughly looks like this...
Code:
SAMPLE
BSF PORTB,1 ;make clock high
MOVWF PORTB,2 ;read the data input and store it in W (WRONG)
MOVLW PORTA,0 ;send the data bit to output (WRONG)
NOP ;wasted cycle, to equal m/s ratio of clock.
BCF PORTB,1 ;make clock low
DECFSZ Count,1 ;count = 16 for the sub' to run 16 times, dec count
GOTO SAMPLE ; if count is non-zero take another sample
RETURN ;if count is zero, go back to main program
As you can see, lines 2 and 3 are incorrect, but it shows what I want to do.
Timing is critical, the maximum number of cycles for a sample is 6 or 8.
So thats 3 (or 4) instruction cycles for the clock high, and the same for the clock low. Say the sample would take 8 cycles, just for convienience..
Therefore, 2 cycles of the 8 are used to make the clock high/low, leaving 6 cycles to read the data, send it to output, decrement reg, AND goto SAMPLE. This really is a lot to do in 8 instruction cycles. :shock:
You see, I'm using the PIC16F84A with a 20MHZ clk, giving an instruction period of 200ns. For 8 cycles per sample, = 1.6uS for each bit.
Notes:
The mark/space ratio of the clock is not really important, as long as its above 20ns, (10th of a cycle).
More than 1 bit, cannot be stored, basically, I'm sending the data
out 'on-the-fly'.
The upper limit on the number of instruction cycles for retrieving a bit from the ADC is 8 (inc. subroutine calls, and return, which take 2 cycles)
I really hope someone can provide some alternatives (writing in another language?) because this is the only problem I have with my project, is this is solved, its plain sailing from here on.
Blueteeth, (email: paranoidfoo@hotmail.com)