re programming in ccs picc compiler

Discussion in 'Programmer's Corner' started by ashrok, Apr 4, 2009.

  1. ashrok

    Thread Starter Member

    Feb 22, 2009
    13
    0
    hi all,
    i tried doing the example program for bulk transfers in usb emulating rs232 for pic18f4550.
    An array ,with values that resemble a sine wave, was already assigned in that example program. i got that working.

    now i want to use the internal adc (an0, with sampling freq fosc/2) and store the sampled values instead of that array mentioned previously.

    I initialized the adc setup in the main function and then called a function which is 'for 'looped to get 256 sample data and store it in an array....

    #define SINE_TABLE_SIZE 256 ///global declarations
    static int sine_table[SINE_TABLE_SIZE];
    void arraysine(void){
    int1 i;
    int8 value;
    for(i=0;i<256;i++){
    set_adc_channel(0);
    delay_us(10);
    value = read_adc();
    sine_table=value;
    }


    is this correct, or any other suggestions

    reply
    thank you.
     
Loading...