3

I'm going crazy to resolve this problem: i need to configure my Analog Discovery to read data sent by PC to Arduino over RX pin. PC and Arduino communicate via UART protocol standard, with 1 start bit, 8 data bits and 1 stop bit. I tried to sample the signal over RX pin using a divider for the Analog Discovery frequency.

The questions: sample reads by Analog Discovery is the real bit value transmitted? I have to read data bit by bit using a 1bit sample or there're a way to read all 8 (+2) bits using a 10bits sample at 1/10 of real baud rate?

There's a portion of python script code for second solution:

[...]

# baud rate for arduino uno is 9600 / 10 byte
# sample rate = system frequency / divider, 100MHz/104166.6p = 960Hz
dwf.FDwfDigitalInDividerSet(hdwf, c_int(104166))

# with this command we setup the incoming frame on 10 bit
dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(10))

# we instantiate a pool of 10 samples
cSamples = 10
rgwSamples = (c_uint8*cSamples)()
dwf.FDwfDigitalInBufferSizeSet(hdwf, c_int(cSamples))

# disable auto trigger
dwf.FDwfDigitalInTriggerAutoTimeoutSet(hdwf, c_double(0))
# one of the analog in channels
dwf.FDwfDigitalInTriggerSourceSet(hdwf, trigsrcDetectorDigitalIn)

# with this command, we demand for a sampling after trigger in a buffer
# which has same specified size
dwf.FDwfDigitalInTriggerPositionSet(hdwf, c_uint(cSamples))

#dwf.FDwfAnalogInTriggerConditionSet(hdwf, trigcondRisingPositive)

#With this command we setup the falling edge triggered on the channel 0
#each field of the function is a bitmask
dwf.FDwfDigitalInTriggerSet(hdwf, 0, 0, 1, 0)

#give it the time for a breath!
time.sleep(1)

#let's begin the acquisition
dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1))

while sts.value != stsDone.value:
    dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts))

# get samples, byte size
dwf.FDwfDigitalInStatusData(hdwf, rgwSamples, cSamples)

samples = [0] * cSamples

rgpy=[0.0]*len(rgwSamples)
for i in range(0,len(rgpy)):
    rgpy[i]=rgwSamples[i]
    samples[i] = rgpy[i]

[...]

Thanks for support!

0 Answers0