spi and shiftin/out


Closed Thread
Results 1 to 3 of 3
  1. #1
    scorpion's Avatar
    scorpion Guest

    Default spi and shiftin/out

    Hi Im using a qt511 touch sensor from qprox.com and im having problems communicating with it.
    basically i cant read and im assuming that i cant write to it either.
    here are some code snipits.
    ---------------------------------------------------------------
    include "modedefs.bas"
    define shift_pauseus 40
    Define OSC 20 '20Mhz HS xtal

    sdo var porta.0
    sdi var porta.1
    sclk var porta.2
    drdy var porta.3
    ss var porta.4
    det var porta.5

    TRISA = %101010
    TRISB = %00000001
    TRISC = %00110000

    ADCON1 = %00001111
    ccp1con = 0
    ccp2con = 0

    high sclk
    high led1
    high led2
    high led3

    'allow touch sensor to calibrate

    high ss

    for i = 1 to 500
    pause 1
    USBService
    next i
    calibratesensor:

    if drdy = 1 then goto MainLoop
    pause 1
    goto calibratesensor

    MainLoop:
    if sensorprepped = 0 then gosub sensorprep
    if drdy = 1 then
    if driftcntr > 100 then
    gosub driftcomp
    driftcntr = 0
    else
    gosub gettouch
    endif
    endif
    led1 = ~ touched


    GetTouch:

    low ss
    pauseus 15
    shiftin sdi, sclk, 6, [touchin]
    toucher = touchin & %10000000
    if toucher = 0 then
    touched = FALSE
    else
    touched = TRUE
    endif
    sensorprepped = 0
    return

    driftcomp:
    low ss
    pauseus 15
    shiftout sdo,sclk, 5, [3]
    sensorprepped = 0

    return

    sensorprep:
    high ss
    pauseus 15
    low ss
    pauseus 2
    high ss
    sensorprepped = 1
    driftcntr = driftcntr + 1
    return


    PS. no oscilloscope just 3 onboard leds.......


    sorry thats so long.
    if anyone can spot what im doing wrong i would really appreciate it.
    tia

  2. #2
    scorpion's Avatar
    scorpion Guest


    Did you find this post helpful? Yes | No

    Default please?

    anyone have any help to offer?
    Im really stuck here

  3. #3
    scorpion's Avatar
    scorpion Guest


    Did you find this post helpful? Yes | No

    Default anyone?

    if i can provide any more info i would be glad to... can anyone help?

Similar Threads

  1. Faster Clock Speed for Shiftin/out?
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th December 2005, 02:15

Members who have read this thread : 1

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