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] pic 16f1824 problem with internal oscillator

Status
Not open for further replies.
thanks tahmid,finally i manage the clock frequency by setting osccon register ..but uart is not working my code is given below ..please help me...


void main()
{
OSCCON=0x72;
ANSELA=0;
TRISA0_bit=0;
UART1_Init(9600);
delay_ms(500) ;
TXCKSEL_bit=1;
RXDTSEL_bit=1;
CPSON_bit=0;
C1ON_bit=0;
GIE_bit=0;

TRISA1_bit=1;
TRISC5_bit=0;


TRISC4_bit=1;


// initialize UART1 module


while (1)
{
TXREG=0x01;
Delay_100ms();

} }
 

You have only initailized UART with 9600 baud. Where is the UART1_Read(), UART1_Read_Text(), UART1_Write(), or UART1_Write_Text() function?
What is your clock frequency? You have to Set comparator register properly. Actually you have to disable the comparators because they are connected to RA0 and RA1 pins.
 

You have only initailized UART with 9600 baud. Where is the UART1_Read(), UART1_Read_Text(), UART1_Write(), or UART1_Write_Text() function?
What is your clock frequency? You have to Set comparator register properly. Actually you have to disable the comparators because they are connected to RA0 and RA1 pins.

thank you for your reply
clock 8 mhz
i have set c1on_bit=0 and c2on_bit=0
but no change
 

What change are you expecting without sending are receiving any data?

Open your project in mikroC Pro and go to menu Project>Edit Project...

See attached image. Make your settings like that. Remove OSCCON settings in your code.
 

Attachments

  • settings.jpg
    settings.jpg
    127.6 KB · Views: 121
Last edited:

On your keyboard, press Ctrl + Shift + E. At the top of the window that pops up, you have "Oscillator Selection", select INTOSC.

Hopet this helps.
Tahmid.
yeah i initially set like that but when i give a 1000 ms delay it will give a 10 - 15 seconds of delay.then i changed the osccon register and loaded with 0x72 the the delay was almost correct

- - - Updated - - -

instead of uart_write() i used txreg

- - - Updated - - -

i used txreg=0x01 instead of uart_write(0x01) ,is there any problem writing like that?

- - - Updated - - -

What change are you expecting without sending are receiving any data?

i used txreg=0x01 instead of uart_write(0x01) ,is there any problem writing like that?

- - - Updated - - -

i used txreg=0x01 instead of uart_write(0x01) ,is there any problem writing like that?
 


You have only initailized UART with 9600 baud. Where is the UART1_Read(), UART1_Read_Text(), UART1_Write(), or UART1_Write_Text() function?
What is your clock frequency? You have to Set comparator register properly. Actually you have to disable the comparators because they are connected to RA0 and RA1 pins.

thank you for your reply
clock 8 mhz
i have set c1on_bit=0 and c2on_bit=0
but no change
 

You have only initailized UART with 9600 baud. Where is the UART1_Read(), UART1_Read_Text(), UART1_Write(), or UART1_Write_Text() function?
What is your clock frequency? You have to Set comparator register properly. Actually you have to disable the comparators because they are connected to RA0 and RA1 pins.

thank you for your reply
clock 8 mhz
i have set c1on_bit=0 and c2on_bit=0
but no change

- - - Updated - - -

yes MCLR is pulled up

- - - Updated - - -

read my last post, it is updated. I don't know about writing to TXREG. I use UART Library functions in mikroC Pro. Are you sure writing a byte to TXREG will transmit the byte to Virtual Terminal?

See this link http://saeedsolutions.blogspot.in/2012/11/pic16f877-uart-code-proteus-simulation.html

Can you show me these registers in datasheet? mention the page nos.

TXCKSEL_bit=1;
RXDTSEL_bit=1;
CPSON_bit=0;

122 and 333

- - - Updated - - -

it is not working.but when i tried to toggle a port pin it worked
so it is clear that pic is working
the problem is with uart
i dont know how to clear it
please help me

- - - Updated - - -

What? You reposted your last post. Have you pulled-up MCLR pin to Vcc? If not, do it. Can you post your circuit?

i have checked voltages at mclr and vdd it is about 4.7 v
 

I saw about that registers. you are sending 0x01 to TXREG. See ASCII table 0x01 means SOH. Maybe it doesn't have a character. Try sending 48 decimal or 0x30. You should get character 0 on hyperterminal/proteus virtual terminal.

Also try UART1_Write('A'); and see if it outputs character A.

Also try setting TRISA0_bit = 1; and TRISA1_bit = 1;
 
I saw about that registers. you are sending 0x01 to TXREG. See ASCII table 0x01 means SOH. Maybe it doesn't have a character. Try sending 48 decimal or 0x30. You should get character 0 on hyperterminal/proteus virtual terminal.

Also try UART1_Write('A'); and see if it outputs character A.

Also try setting TRISA0_bit = 1; and TRISA1_bit = 1;
i tried with uart1_write('*');
didnt work.
setting both pins as input,i thought transmitter must be output..
let me try it
 

Did you select internal oscillator in the configuration settings? Do select it. Then, set the frequency of operation using the OSCCON register and the OSCTUNE register.
 

Did you select internal oscillator in the configuration settings? Do select it. Then, set the frequency of operation using the OSCCON register and the OSCTUNE register.

i have configured OSCCON ,Why should we configure OSCTUNE ,We have already set bits for 8mhz in osccon register is is necesseray to load values in OSCTUNE

- - - Updated - - -

OK. i got the output properly but using external oscillator. The problem is with Internal oscillator for sure. I will try to solve.

What is the frequency of the crystal you used in the circuit
 

OSCTUNE is necessary to calibrate the oscillator frequency. You can make do without setting OSCTUNE. Did you select internal oscillator in the configuration settings in mikroC?
 

Did you disable PLL in the configuration settings?

There is a configuration setting "PLL enable". Disable it.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top