how to send data from board to output pin ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

hello I want for my project to send from my board to out pin a serios of bits 1 or 0 meaning the i will get

a serios of ones and zeros.png

and again i dont want to use wavedac i want to send signals of 1 or 0 manually

0 Likes
1 Solution

Without knowing any additional information, it seems like you have a number of options to do this.

You could write a function in software to write out 1s and 0s from a word manually, shifting out the bits manually by using Pin_Write().  That could look something like:

void Send_Byte(uint8_t out_byte){

    uint8_t i, out_bit;

    pin_write(0);    //ensure signal starts at 0

    for (i=0,i<8,i++){

        out_bit = (out_byte >> i) & 0x01;

        pin_write(out_bit); //Put bit onto the output pin

        CyDelay(5); //bit time 5mS

    }

    pin_write(0);   //return line to 0

}

You could also use a Shift Register component and connect shift_out to the output pin, which will shift out the bits onto the pin at the speed of the clock connected to the component.  This would let the hardware shift handle the byte.

View solution in original post

0 Likes
7 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I need a little more information do you want this done by switches or just have the pulses appear some place in the code.  Also what voltage levels do you need and what PRF and what PRI. If  you just need pules on a pin you can do that just from software. .

0 Likes

Without knowing any additional information, it seems like you have a number of options to do this.

You could write a function in software to write out 1s and 0s from a word manually, shifting out the bits manually by using Pin_Write().  That could look something like:

void Send_Byte(uint8_t out_byte){

    uint8_t i, out_bit;

    pin_write(0);    //ensure signal starts at 0

    for (i=0,i<8,i++){

        out_bit = (out_byte >> i) & 0x01;

        pin_write(out_bit); //Put bit onto the output pin

        CyDelay(5); //bit time 5mS

    }

    pin_write(0);   //return line to 0

}

You could also use a Shift Register component and connect shift_out to the output pin, which will shift out the bits onto the pin at the speed of the clock connected to the component.  This would let the hardware shift handle the byte.

0 Likes

yes but we have no ideal what he is trying to do to get to the end result.

0 Likes
Anonymous
Not applicable

ye that is exactly what i want to do!!!  to see pules on scope

0 Likes
  1. void Send_Byte(uint8_t out_byte){ 
  2.     uint8_t i, out_bit; 
  3.     pin_write(0);    //ensure signal starts at 0 
  4.     for (i=0,i<8,i++){ 
  5.         out_bit = (out_byte >> i) & 0x01; 
  6.         pin_write(out_bit); //Put bit onto the output pin 
  7.         CyDelay(5); //bit time 5mS 
  8.     } 
  9.     pin_write(0);   //return line to 0 

This code will work if that all you want to do is put a pulse on the scope.

KyTr_1955226
Level 6
Level 6
250 sign-ins 10 likes given 50 solutions authored

Worth noting though, if you actually want to send data and have something read it on the other end (not just see the bits on a scope) you would probably be better off using an actual UART or I2C.

With the code I posted, there's no way for a receiver on the other end to tell the difference between the 0V idle signal and the a leading zero of a byte.  You would need a start bit of some kind to tell the receiver that a transmission is starting.  A UART would handle start/stop bits automatically

Anonymous
Not applicable

ok thank you all for the help

0 Likes