CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

re programming in ccs picc compiler

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ashrok88
Guest







re programming in ccs picc compiler
PostPosted: Sat Apr 04, 2009 11:03 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 04, 2009 11:40 am     Reply with quote

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

View user's profile Send private message

thank you for the reply
PostPosted: Sat Apr 04, 2009 1:03 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Apr 04, 2009 1:05 pm     Reply with quote

just for the code and the example code to be consistent Very Happy
Guest








PostPosted: Sun Apr 05, 2009 11:39 am     Reply with quote

hi
can any1 reply..
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Apr 05, 2009 11:44 am     Reply with quote

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
PostPosted: Sun Apr 05, 2009 12:10 pm     Reply with quote

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







PostPosted: Sun Apr 05, 2009 12:15 pm     Reply with quote

or fosc_internal
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group