Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] How can I produce 9Khz PIC16F628A - MikroC

Status
Not open for further replies.

Aseng

Newbie level 4
Joined
Dec 27, 2015
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
47
Hi all Members,
Can anyone one here help me.

I want to get at a pin with PIC16F628A to produce frequency at 9Khz with external crystal oscillator 4mhz.


Thanks.
Ase.
 

Hi,

microchip has application notes about the use of timer/counters and frequency generation.

There are a lot forum threads.
There are internet tutorials, example code, even videos.

************
Show what documents/informations you refer to.
Show what your idea is, your calculations, your code.
Tell us what you expected and what you see instead.
Ask elaborated (and not global "can anybody help") questions.

In short: show your effort ... and there will be many people here to help you.


Klaus
 

How accurate does it have to be?

If 9.009KHz is near enough you can use the PWM module:
PR2 =0x6E
T2CON = 0x04
CCPR1L = 0x37
CCP1CON = 0x1C

That will give a 50% square wave, if you want to vary the pulse width without changing frequency, change the values in CCPR1L and CCP1CON.

Brian.
 
  • Like
Reactions: Aseng

    Aseng

    Points: 2
    Helpful Answer Positive Rating
Hi Brian,
I forgot to attached the picture, here is the simulation as well as your advice.

Dank Jee Well. 2018-07-19 at 19-28-39.png
 

Hi TheMartin,
Could you please show me your code use mikroC Timer Calculator.
 

Try this code.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void main() {
    CMCON = 0x07;
    
    TRISA = 0x00;
    TRISB = 0x00;
    
    PORTA = 0x00;
    PORTB = 0x00;
    
    PWM1_Init(9000);
    PWM1_Set_Duty(127);
    PWM1_Start();
    
    while(1) {
    
    
    }
}

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top