| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			sifirzero1
 
 
  Joined: 14 Dec 2022 Posts: 50
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| ccs c book | 
			 
			
				 Posted: Wed Jan 04, 2023 2:21 pm     | 
				     | 
			 
			
				
  | 
			 
			
				 | 
			 
		  | 
	
	
		  | 
	
	
		
			sifirzero1
 
 
  Joined: 14 Dec 2022 Posts: 50
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Jan 04, 2023 2:22 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Who has the book on this site? Would you sell or gift the book? thanks
 
 
http://janniehamman.co.za/ | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sat Jan 07, 2023 9:35 am     | 
				     | 
			 
			
				
  | 
			 
			
				One of the best ways to learn CCS C , is to look at the 100s of example programs that CCS supplies in the 'examples' folder !
 
You can also see working programs in the 'code library' on this forum.
 
 
I went to the website for that book, but didn't see any examples of his code | 
			 
		  | 
	
	
		  | 
	
	
		
			sifirzero1
 
 
  Joined: 14 Dec 2022 Posts: 50
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sat Jan 07, 2023 9:42 am     | 
				     | 
			 
			
				
  | 
			 
			
				| because the book is on sale. didn't share much | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sat Jan 07, 2023 10:26 am     | 
				     | 
			 
			
				
  | 
			 
			
				Most writers will show a sample of what's inside the book.
 
I will NOT buy that book without seeing something.
 
 
Would you buy a car without actually seeing it ? | 
			 
		  | 
	
	
		  | 
	
	
		
			sifirzero1
 
 
  Joined: 14 Dec 2022 Posts: 50
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sat Jan 07, 2023 10:32 am     | 
				     | 
			 
			
				
  | 
			 
			
				| website has samples at the bottom of the page and images from the book | 
			 
		  | 
	
	
		  | 
	
	
		
			temtronic
 
 
  Joined: 01 Jul 2010 Posts: 9589 Location: Greensville,Ontario 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sat Jan 07, 2023 10:47 am     | 
				     | 
			 
			
				
  | 
			 
			
				hmm, I didn't scroll down to the end...just to the 'buy it now' info...
 
I did download the 7segment code.
 
It has an error in the first few lines..
 
 
hint the PIC doesn't have a 16 bit ADC... | 
			 
		  | 
	
	
		  | 
	
	
		
			sifirzero1
 
 
  Joined: 14 Dec 2022 Posts: 50
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sat Jan 07, 2023 11:25 pm     | 
				     | 
			 
			
				
  | 
			 
			
				| shall I not buy the book? is it naughty | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sun Jan 08, 2023 1:50 pm     | 
				     | 
			 
			
				
  | 
			 
			
				I say don't buy.  His Accelerometer  program has bugs.
 
http://janniehamman.co.za/progs/accel355.c
 
 
In his main loop, he is not doing the acquisition delay after changing the
 
adc channels:
 
 	  | Code: | 	 		  void main()
 
{
 
   setup_adc_ports(sAN0|sAN1|sAN2);
 
   setup_adc(ADC_CLOCK_INTERNAL);
 
 
   while(TRUE)
 
   {
 
 
      set_adc_channel(0); 
 
      rax=read_adc();
 
      ax=calcxy(rax);   
 
      
 
      set_adc_channel(1);
 
      ray=read_adc();
 
      ay=calcxy(ray);
 
      
 
      set_adc_channel(2);
 
      raz=read_adc();
 
      az=calcz(raz);
 
       | 	  
 
The acquisition time is given in this section of the 16F88 data sheet:
 
12.1 A/D Acquisition Requirements (page 119)
 
It is listed in the equations as 19.72 us.  His code should look like this:
 
 	  | Quote: | 	 		  
 
set_adc_channel(0);   
 
delay_us(20);
 
rax=read_adc();    
 
ax=calcxy(rax);      
 
      
 
set_adc_channel(1);
 
delay_us(20);
 
ray=read_adc();
 
ay=calcxy(ray);
 
      
 
set_adc_channel(2);
 
delay_us(20);
 
raz=read_adc();
 
az=calcz(raz);
 
 | 	  
 
 
Also, his ADC setup is this:
 
 	  | Code: | 	 		  | setup_adc(ADC_CLOCK_INTERNAL); | 	  
 
But the 16F88 data sheet says on page 120:
 
 	  | Quote: | 	 		  2: When the device frequencies are greater than 1 MHz, the RC A/D 
 
conversion clock source is only recommended for Sleep operation. | 	  
 
He is running at 8MHz, therefore his setup should be:
 
 	  | Code: | 	 		  | setup_adc(ADC_CLOCK_DIV_16) | 	  
 
The DIV_16 value comes from this table in the PIC data sheet:
 
TABLE 12-1: TAD vs. MAXIMUM DEVICE OPERATING FREQUENCIES
 
on page 120.  16F88 data sheet:
 
https://ww1.microchip.com/downloads/en/devicedoc/30487c.pdf | 
			 
		  | 
	
	
		  | 
	
	
		 |