Triggering 5 TTL clocks simultaneously


Closed Thread
Results 1 to 40 of 84

Hybrid View

  1. #1
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    What if I did something like this??

    horizloop:
    PORTB.2 = 0
    PORTB.3 = 1
    PAUSEUS 139
    ENABLE
    ON INTERRUPT GOTO H2lock
    DISABLE
    PAUSEUS 15
    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
    PAUSEUS 87
    horizpulse = horizpulse + 1
    IF horizpulse < 784 THEN
    GOTO horizloop
    ELSE
    PAUSEUS 270
    GOTO vertloop
    ENDIF

    H2lock:
    PORTB.3 = 0
    PORTB.2 = 1
    RESUME

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    NOP, On Interruot goto is placed at the header of your code before your main loop. Since it's working in background, it will jump by himself to the interrupt routine. did you look at my previous link?

    INTCON and probably others have to be set for interrupt type/source.

    i'll make something like this later today.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    What do you think of something like this>?

    ' 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

    ON INTERRUPT GOTO H2lock ' When Reset clock is high
    INTCON1 = %1001000 ' Enable RB0 Interrupt
    INTCON = $80 ' Disables Interrupts
    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %00001101 ' Set PORTA analog, except for pin 2
    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 PORTA.2 = 1 then
    GOTO vertloop
    else
    GOTO buttonloop ' Waits for 5V that signals shutter is closed
    ENDIF
    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
    ENDIF
    horizloop:
    PORTB.2 = 0
    PORTB.3 = 1
    PAUSEUS 139
    INTCON = $80 ' Re-enables interrupts
    PAUSEUS 15
    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
    PAUSEUS 87
    horizpulse = horizpulse + 1
    IF horizpulse < 784 THEN
    GOTO horizloop
    ELSE
    PAUSEUS 270
    GOTO vertloop
    ENDIF

    DISABLE
    H2lock:
    PORTB.3 = 0
    PORTB.2 = 1
    RESUME
    ENABLE
    END

  4. #4
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    Also, I saw a blurb in the PBP manual about the fact that I can check the interrupt flag without actually enabling interrupts. If I did it that way, then I could merely do a check condition statement, similar to this, right?:

    IF PORTB.2 = 1 AND INTERRUPTFLAG = 1 ' When horizontal 1 is high and reset is high

    ' Do the H1 > low, H2 > high, ADC conversion and the SEROUT2

  5. #5
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    OK, I checked the datasheet and the interrupt flag bit is bit 1 of the INTCON register. It also says that I have to reset it in software once an interrupt has occurred. So I was thinking if I just set the INTCON.1 = 0 right before the condition statement, then I could just wait until the INTCON.1 = 1 before clocking the horizontals. What do you think?

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Yep. I do this all the time.

    Disable global interrupts (INTCON.7 = 0), and just monitor & reset interrupt flags as needed. Very handy.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    Should I still enable the INTCON1 register? I have it set to %1001000 to use the RB0 interrupt. I have the HWPM (which is to be the interrupt source) set as follows:

    HPWM 1,64,3600 ' Supposed to send HPWM 3.6KHZ at 25% duty

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. How do I set GPIO 0-2 and 5 simultaneously?
    By cstack in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th August 2009, 09:32
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. Replies: 11
    Last Post: - 13th July 2005, 19:26

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts