Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Can my program send and receive data through FPGA? im new to c programming

Status
Not open for further replies.

Gary92

Newbie level 1
Joined
Aug 14, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
6
PHP:
#include <mcu codes.h>
#include <usb_cdc.h>


#define input_CLK PIN_B0 
#define pin_1 PIN_B3
#define input_data PIN_B4
#define input_LED PIN_D1

 void main() 
 {    
    usb_cdc_init();
    usb_init();
    usb_wait_for_enumeration();
    
    int1 data[4];
    int i;
    int1 received_data=0;
    int1 data_input=0;
    int1 data_input1=0;
    
    output_high(input_LED); 
    
    while(!usb_cdc_kbhit())
    {
      for(i=0; i<4; i++)
     {
         data[i] = i+1;
     
         switch(data[i])
      {
      case 1: data[0] = 1;
      break;
      case 2: data[1] = 0;
      break;
      case 3: data[2] = 0;
      break;
      case 4: data[3] = 1;
      break;
      }
      
      output_bit(pin_1, data[i]);
      
      delay_ms(100);
      output_high(input_CLK);
      delay_ms(100);
      output_low(input_CLK);
      delay_ms(100);
      }
      
      output_low(input_LED);
      delay_ms(100);
      
    for(i=0; i<8; i++)
    {
      output_high(input_CLK);
      delay_ms(100);
      output_low(input_CLK);
      delay_ms(100);
      received_data = input_State(input_data);


         if(received_data==1)
         {  
           data_input += received_data;
           printf(usb_cdc_putc,"%d", data_input);
         }
         else
         {
            if(received_data==0)
         {
            data_input1 += received_data;
            printf(usb_cdc_putc,"%d", data_input1);
         }
         
    }
 }        
    }
    }

i am getting the output data of 1010 instead of 1001 by using oscilloscope to test on pin_1.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top