Hello
The problem I present here is a little weard because I could not find any documentation for anybody else needing this.
My device must measure spectrography data while pulsing a high power light source. So the code looks like this:
start
- high PORTA.0 pin to start laser
- read measurements & output to PORTC
- pause x
- low PORTA.0 pin to turn off laser
- read measurements & output to PORTD
- pause x
- goto start.
or some PBP sample code:
define OSC 20
result var byte
pause_time var word : pause_time = 3000 ; (3.000 pulses per second)
period_ms var byte
period_us var byte
main:
high porta.0
gosub ADC_read
portc = result
gosub pause_for_period_of_time
low porta.0
gosub adc_read
portD = result
gosub pause_for_period_of_time
goto main
adc_read:
; read stuff from some high speed soviet golden capsule military aircraft chip connected to 8 bit PORTB
; high portE to enable chip, read the portB, low portE to disable the chip
return
pause_for_period_of_time:
period_ms = pause_time.byte1
period_us = pause_time.byte0
; pause the program so I can totaly get the frequency I specified at beginning (3.000Hz or 4.231Hz or something between 1Hz and 10Hz with three digits after decimal point)
pause [asylum/madhouse formula without floating point unit]
return
The problem is I must somehow redefine "pulsout" function so I can take measurements immediately after the pin is high, and again to take measurements after the pin is low. Or somehow find a formula to determine the period formula from the given frequency by using digital logic, as this pic does not have a FPU. Or to get in contact with Jedi Master of Assembler.
My XTAL frequency is 20MHz to be able to work with microseconds.
the program works, I can gather data but I did something like this:
pause for sine fraction of period in ms
for i=0 to 256 : pause "i" times the period in US : next i.
This is garbage but at least I have a variable pulse and I can do measurements between pin going from low to high and from high to low.
Any ideas will be welcomed.
Bookmarks