PIC16F1939 PORT, EUSART and LCD configuration/set up

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Re: PIC16F1939 PORT, EUSART and LCD configuration/set up

Postby Brian Griffin » Tue Aug 16, 2011 10:18 am

PICTRAIL WROTE:Here is a link to its datasheet...
http://ww1.microchip.com/downloads/en/D ... 41574A.pdf


Is the Hi-Tech compiler updated?

I need this version info before I can comment further. Please check for the compiler version and date.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: PIC16F1939 PORT, EUSART and LCD configuration/set up

Postby PICTRAIL » Tue Aug 16, 2011 12:52 pm

Yes Brian... The HiTech Compiler is updated i'm using it for other processors aswel.
Thanks for your anticipated support.

Best Regards.
PICTRAIL
Apprentice
 
Posts: 40
Joined: Mon Dec 27, 2010 3:32 pm

Re: PIC16F1939 PORT, EUSART and LCD configuration/set up

Postby Brian Griffin » Tue Aug 16, 2011 1:40 pm

PICTRAIL WROTE:Yes Brian... The HiTech Compiler is updated i'm using it for other processors aswel.
Thanks for your anticipated support.

Best Regards.


Have you list down explicitly on the configuration in your code, like OSC speed and all that? Some compilers are really picky about their configurations.

And also, try not to depend too much on the simulation. On times it may give a false alarm.

ober WROTE:Brian, any model that I can try searching for the newer model? Would really like to take a look. 8-)


PIC 16F150X series.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: PIC16F1939 PORT, EUSART and LCD configuration/set up

Postby PICTRAIL » Tue Aug 16, 2011 1:52 pm

Thanks! I did tried. Ports are working for LED's but the LCD character displayed is different from what i sent likewise UART also not responding. Meanwhile, same code was used on PIC16F877A and worked perfectly so i know its configuration problem.
Between, any idea on how to solve this error message on the Pickit 2 programmer "Warning: No configuration word in hex file".

Regards.
PICTRAIL
Apprentice
 
Posts: 40
Joined: Mon Dec 27, 2010 3:32 pm

Re: PIC16F1939 PORT, EUSART and LCD configuration/set up

Postby Brian Griffin » Tue Aug 16, 2011 1:57 pm

PICTRAIL WROTE:Thanks! I did tried. Ports are working for LED's but the LCD character displayed is different from what i sent likewise UART also not responding. Meanwhile, same code was used on PIC16F877A and worked perfectly so i know its configuration problem.
Between, any idea on how to solve this error message on the Pickit 2 programmer "Warning: No configuration word in hex file".

Regards.


Okay - do you have a sample code which I can 'port' it to my MikroC compiler? I can compile it and see what happened.

On times some compilers can behave funny, even MikroC, I admit.

P.S: Please list down ur pins and what does it do on your code.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: PIC16F1939 PORT, EUSART and LCD configuration/set up

Postby robosang » Tue Aug 16, 2011 7:25 pm

Woh... checking the datasheet showing this is very good featured PIC.... should have try it! Let me get one to try out.

Anyway, studying the oscillator diagram, I am curious to know how do you get 20MHz from Internal oscillator? What is the configuration and setting that output 20MHz to system CPU?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: PIC16F1939 PORT, EUSART and LCD configuration/set up

Postby PICTRAIL » Wed Aug 17, 2011 12:06 am

In the configuration word, FOSC_HS was declared.
CODE: SELECT_ALL_CODE
#define XTAL_FREQ   20MHZ   //Set PIC clock frequency to 20MHz
PICTRAIL
Apprentice
 
Posts: 40
Joined: Mon Dec 27, 2010 3:32 pm

Re: PIC16F1939 PORT, EUSART and LCD configuration/set up

Postby robosang » Wed Aug 17, 2011 10:18 am

PICTRAIL WROTE:In the configuration word, FOSC_HS was declared.
CODE: SELECT_ALL_CODE
#define XTAL_FREQ   20MHZ   //Set PIC clock frequency to 20MHz


So this is the bug, might be only this causing failure, might not only be this.
PIC16F1939 Oscillator.JPG

If you look at the diagram, there is no way you can get 20MHz from Internal oscillator.

FOSC_HS should be external High Speed Crystal Oscillator, not internal :D . And define XTAL_FREQ is just simply letting compiler know what is the clock speed you are using, it is not to configure PIC to use that speed. You need to make that clear.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: PIC16F1939 PORT, EUSART and LCD configuration/set up

Postby yonghui » Fri Aug 19, 2011 9:32 am

hi,

proper setup of configuration bits .
CODE: SELECT_ALL_CODE
//configuration bits
__CONFIG(FOSC_INTOSC&WDTE_OFF&PWRTE_ON&MCLRE_OFF&CP_ON&CPD_ON&BOREN_OFF&CLKOUTEN_OFF&IESO_OFF&FCMEN_OFF);
__CONFIG(WRT_OFF&VCAPEN_RA6&PLLEN_ON&STVREN_ON&LVP_OFF);


if u are using 5V then VCAPEN IS required, else if 3.3v then not needed. the above config is setting the controller to internal oscillator.

below is reference init code:

CODE: SELECT_ALL_CODE
OSCCON=0b11110000;         // setting for 32MHz =8MhzX4

   __delay_ms(20);
//PORT setting
   TRISA = 0b00111011;       //analog=AN0,AN1,AN3,AN4
   ANSELA= 0b00101011;
   TRISB = 0b00011110;      //analog=AN8-AN11
   ANSELB= 0b00011110;
   TRISC =   0b10000000;
   TRISD = 0b00000000;    
   TRISE = 0b00000001;      
   OPTION_REG=0b01111111;
   ANSELE = 0b00000000;   //port E analog disabled


analog select register need to be configured properly for digital or analog uses.

below is register need to be configured for uart:
SPBRGH=?
SPBRGL=?
TXSTA=?
RCSTA=?
RCIE=1;
BAUDCON=0b00001000; //16bits baud reg

above code have been used for PIC16F11937 and PIC16F1933 without any problem



regards,
yh
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: PIC16F1939 PORT, EUSART and LCD configuration/set up

Postby PICTRAIL » Fri Aug 19, 2011 2:28 pm

Thank you so much Yonghui...
I will try this and let you know about the response but i believe it should work...
Once more, thank you so much...
PICTRAIL
Apprentice
 
Posts: 40
Joined: Mon Dec 27, 2010 3:32 pm

Previous

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 6 guests

cron