View previous topic :: View next topic |
Author |
Message |
ashrok88 Guest
|
re programming in ccs picc compiler |
Posted: Sat Apr 04, 2009 11:03 am |
|
|
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.
Code: |
#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[i]=value;
}
|
I compiled it and loaded the hex into the pic but usb is not detected.
Any suggestions to make it work?
reply
thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Apr 04, 2009 11:40 am |
|
|
Quote: | int1 i;
for(i=0;i<256;i++){ |
What is the maximum value that an 'int1' variable can hold ?
Also, what is the maximum size that an 'int8' variable can hold ? |
|
|
ashrok
Joined: 04 Apr 2009 Posts: 2
|
thank you for the reply |
Posted: Sat Apr 04, 2009 1:03 pm |
|
|
oh.....
I realize the mistake now,
I changed it to int16 for both..
Is the code fine otherwise??
I get no errors on compiling..but
Is there anything I need to include for the device to be detected?
(I commented out the parameter settings inside main when we choose read options from project wizard and also the file inclusion part that contains my project path) |
|
|
ashrok
Joined: 04 Apr 2009 Posts: 2
|
|
Posted: Sat Apr 04, 2009 1:05 pm |
|
|
just for the code and the example code to be consistent |
|
|
Guest
|
|
Posted: Sun Apr 05, 2009 11:39 am |
|
|
hi
can any1 reply.. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Apr 05, 2009 11:44 am |
|
|
Quote: | Now I want to use the internal adc (an0, with sampling freq fosc/2) | This ADC setting is legal for a maximum device clock of 2.8 MHz, which seems rather unlikely in USB operation. Did you notice the ADC acquisition time requirements in the datasheet? |
|
|
ashrok88 Guest
|
hi |
Posted: Sun Apr 05, 2009 12:10 pm |
|
|
yes the example uses bulk type of data transfer,,,
is it ok if i change the adc_setup to fosc/64 ?
in the example it transfers 512 bytes data..
regards
Ashrok |
|
|
ashrok88 Guest
|
|
Posted: Sun Apr 05, 2009 12:15 pm |
|
|
or fosc_internal |
|
|
|