Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic18f252

Status
Not open for further replies.

darkfeffy

New Member
Hi all,
I am quite new to the pic family and need some help on how to do smooth sinusoidal pwm on 18f252:

(1) how do I modify the CCP1CON<5:4> bits in one operation (without affecting the other bits)?

(2) By the way, can I avoid the use of the CCP1CON<5:4> bits? If I use only the CCPR1L register, will this affect the results terribly?

(3)please, what circuit can I use to program the pic (reference)?

Thanks for your patience
Ed:D
 
There are two assembly instructions that can be used to toggle individual bits.
F is the register, b is the bit. Don't refrene the bit directly use the labels from your include file for the CCP!CON register.

BCF f,b Bit clear, bit is indexed 0 to 7
BSF f,b Bit set
 
To get an answer to this question, you need to define "terribly" first. You will lose two bits of resolution, how bad it would be depends on application.

Felis, the whole idea is to make a sinusoidal pwm controller for a UPS. If we want a THD of less than say 5% (after filtering of course) can we ignore the two bits without much ado?

Why do these Microchip guys even have to separate the two bits from the CCPR1L register? It makes for a larger number of instructions just to completely define a pwm duty cycle.

Please reference me a suitable programmer for the 18f252.

I still wish to know if I can modify bits 5:4 of CCP1CON in just one operation. You see, the problem is I have stored in flash memory the values that have to be fed to CCP1CON<5:4> but still dont know how to modify these bits without touching the others. Thorn in the flesh...

I appreciate your understanding
Thanks
 
There are two assembly instructions that can be used to toggle individual bits.
F is the register, b is the bit. Don't refrene the bit directly use the labels from your include file for the CCP!CON register.

BCF f,b Bit clear, bit is indexed 0 to 7
BSF f,b Bit set

Thanks Sceadwian,
But I still have a hitch. I have stored in flash memory the value supposed to go in to CCP1CON <5:4>. But I don't know how to feed in this value without crushing the other bits.
Sceadwian I also need to know if the PICDEM MC development board can serve as a programmer. That is I write asm code in MPLAB IDE and load it into the microcontroller using PICDEM MC.
Thanks for your patience
ed
 
Mask out all the bits from the register that you don't want then or them with the other register
 
Felis, the whole idea is to make a sinusoidal pwm controller for a UPS. If we want a THD of less than say 5% (after filtering of course) can we ignore the two bits without much ado?

If you care about THD, use all ten. They are upper bits; if you generate a sine wave, you would never need to change more than one of those in consecutive cycles anyway.

Why do these Microchip guys even have to separate the two bits from the CCPR1L register?
PIC18 registers are 8 bit. 10 bits won't fit in 8 bit register, that's why.
Please reference me a suitable programmer for the 18f252.
My favorite programmer is Microchip ICD-2.
I still wish to know if I can modify bits 5:4 of CCP1CON in just one operation. You see, the problem is I have stored in flash memory the values that have to be fed to CCP1CON<5:4> but still dont know how to modify these bits without touching the others. Thorn in the flesh...
Just store the whole byte and copy that whole byte to ccp1con. The rest of the register is always the same.
 
Hi again,
I bought the PICDEM MC LV Development Board from Microchip for 18f devices, only to realise later that my PIC 18f252 is not listed in their reference document. They mentioned the 18f2431. I have looked at the pinouts of the the two PICs and they are almost identical. However, the 2431 has certain pin functionalities that are absent in the 252.
Is it possible to program the 252 with this very Development board?
Thanks for your patience.
Ed
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top