[SOLVED] PIC complete discussion for all

Status
Not open for further replies.
transmitting and receiving some data between two PIC18f using SPI would give you a clear understanding of SPI protocol.... then you can try out PWM in your PIC ...'''

Then if you spend time to understand FAT file system used in MMC ? SD card, then it will be easy for you, and i am sure you will become expert... but everything takes time...

Dont try to get into too much of WAV or mp3 player now.... time will come when you will be able to do this on your own, if you are good in PWM, SPI, fat file systems...


All the best..
 
transmitting and receiving some data between two PIC18f using SPI would give you a clear understanding of SPI protocol
Ok.. I will try this first..

next is

adc
and
pwm
 

And for everything, I recommend you read the reference manual. It is very helpful. Take a look here:
ww1.microchip.com/downloads/en/devicedoc/33023a.pdf

Hope this helps.
Tahmid.

---------- Post added at 20:52 ---------- Previous post was at 20:51 ----------

It covers everything, or atleast almost everything, you need.
 
In that case, use all the resources you have and start working on them until you think you've earned proficiency in each of the units and then you can "glue" them together for your big project. :grin: And come back here when you need help on something. :smile:
 
Reactions: reza30

    reza30

    Points: 2
    Helpful Answer Positive Rating

yes... thanks for the advice.. I am thinking also the same... I will start my day tomorrow with PIC stuff... hehe

---------- Post added at 17:26 ---------- Previous post was at 17:23 ----------

This thread is my learning thread... hehe
 

hi guys.. I've got a busy day today but still I get to manage to have exercise about my PIC learning..

My activity this afternoon was to activate ADC of my PIC18f4550(in simulation )

I will post my code for future reference of other students..

**broken link removed**

PHP:
#include<htc.h>


void init_adc();
unsigned int adc_read();

void main()
{
	unsigned int adc_value;
	init_adc();
	TRISD = 0x00;
	
	while(1)
	{
		adc_value=adc_read();
		PORTD = adc_value;


	}


}

void init_adc()
{
/* select channel 0, enable ADC */	
	ADCON0bits.ADON = 1; 
/* Voltage reff is VDD, configure AN0 as analog */ 
	ADCON1bits.VCFG0 = 0;
	ADCON1bits.VCFG1 = 0;
	//ADCON1 |= 0b1110;

/*2 x TAD, FOSC/32 */
	ADCON2bits.ACQT0 = 1;
	ADCON2bits.ADCS1 = 1;
	TRISAbits.TRISA0 = 1; // input
	ADCON2bits.ADFM = 0;  // A/D result is left justified
}

unsigned int adc_read()
{
	ADCON0 = 0x00;
	ADCON0bits.ADON = 1; //turn on adc

	ADCON0bits.GO_DONE = 1; //start converstion

	while(GO_DONE); //wait for converstion to finish
	ADCON0bits.ADON = 0; //turn off adc
	
	return ADRESH;

}


Pls evauate my code if Im missing something important.. I spent 3hours for that code because I tried not looking to the work of others I just scan and scan the datasheet of my PIC

---------- Post added at 13:03 ---------- Previous post was at 12:57 ----------

guys, I have a funny story... lol

this day someone approached me to become here private tutor in c++.. LOL.. Im not a good programmer but I know I can teach some basics of C++ like displaying something in the CLI.. lol... haha..

she's paying me $7/hour.. hehe a little amount but that's good than nothing even $1/day... hehe

I like this way, at the same way I think can improve my programming skill.. Im a very bad programmer...:-x

---------- Post added at 13:23 ---------- Previous post was at 13:03 ----------

as you can see im using left justified and discarding the 2 bits in ADRESL.. does it mean I am just like using 8bit adc resolution if I discard the 2bits of ADRESL?
 
Last edited:

I'm not exactly sure about this, but shouldn't the main program/function (the main(){} block) come at the end, after all other subroutines and functions?

Besides that, it looks okay. No need to turn off ADC. You can just keep it on.

as you can see im using left justified and discarding the 2 bits in ADRESL.. does it mean I am just like using 8bit adc resolution if I discard the 2bits of ADRESL?
Yes.

Hope this helps.
Tahmid.
 
shouldn't the main program/function (the main(){} block) come at the end, after all other subroutines and functions?

Usually I use the main at the end of the code after all the other functions but different people may have different preferences.
If you place the main at the end there is no need to declare the function prototypes (void init_adc(); and unsigned int adc_read() because the compiler already knows about them before it enters the main.

Alex
 
writing main function in the begining will not cause any problem... it will work , yes only prototypes need to be defined.... its just programming concept used by programmer....
 
for my own Idea I just declare function prototypes at the beginning because I don't what to see anything as much as possible like functions above main.... I just like that way.. hihi

---------- Post added at 10:17 ---------- Previous post was at 09:46 ----------

today I will do the PWM exercise... hehe
 

Hi I get stuck on PWM.. I get confused of this modules 15.0 CAPTURE/COMPARE/PWM
(CCP) MODULES

If I am going to enable PWM what exactly the register I am going to enable? there are many registers in the datasheet in PWM section... hehe

---------- Post added at 13:12 ---------- Previous post was at 12:53 ----------

I think CCP1CON register is the only responsible here... Im reading again the datasheet..lol

---------- Post added at 13:14 ---------- Previous post was at 13:12 ----------

Let me post here my notes as I go along with the PWM.

my notes:
1.Timer2 is available for modules in PWM mode.
2. CCP1CON register
 

check this for any help

**broken link removed**
 
wow!! excellent.. very nice site.. hehe thanks so much..

---------- Post added at 13:38 ---------- Previous post was at 13:29 ----------

Hi ckshivaram, the link you have given were not able to touch the individual bits of CCP module but at least some theory/configuration is there.. I will just go through with the datasheet first for more information..
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…