Author Topic: LCD PIC16F84 MPLAB  (Read 7189 times)

0 Members and 1 Guest are viewing this topic.

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
LCD PIC16F84 MPLAB
« on: June 13, 2016, 12:10:48 am »
20 May 16
originally posted about two weeks ago MORE QUESTIONS.

Please help me if anyone can. This may get lengthy.
I think I have bitten off more than I can chew.
About me...
I'm 63 years old and not getting any younger.
Total newbie to pics.

A few weeks ago I decided to look into programming a few Pics to drive a 2 x 16 LCD.
I have done some visual basic programming (many years ago) but decided to go the full hog and buy a Pickit 3 clone and learn C.
How many versions of C are there?
While I waited for it to arrive I downloaded MPLAB X IDE.
I found that it has no or very little support for 2 x 16 LCD so I uninstalled it and found it didn't uninstall completely. It left a few folders and files behind. These are outlined in a previous post.

I installed Microchip XC8 v1.37 and with a little help managed to get it running.
I have so far been unable to get a program to work.
I have downloaded complete projects including header files etc and still get errors.

I have watched videos and using the Windows Snipping Tool (very handy tool) pause, copy / past to word and then printed it so I could type the code in.

Just about every line in the code has an error mark in the line number column.
Most of them have a message when I hover the mouse over the error flag like
Unable to resolve identifier Nop.   and nop and NOP
Unable to resolve identifier SetDDRamAddr.
When I try to build the program I always seem to get 2 errors that always seem to be the same.
A snap shot included.

I have also copy/pasted displayed files with the same results.

My main idea is to have the Pic monitor various parts of my power supply.
It comprises of two power supply boards running from 2 separate transformers i.e.
two completely separate Supplies.
 Monitoring
   Over current in both positive and negative supplies taken from the current limit led circuit.
   Variation of over say .25 volts between supplies using a window comparator
   Heat sink temperature etc. Or at least over temperature.

Every input will have an Opto Coupler for full isolation.

The chips I have had for a few years bought in a bulk lot of components are PIC 16F84 20meg.  NOT PIC16F84A...
Once I get a couple of projects working I will buy bigger and more versatile chips and try to do silly things like read the voltages and temperature and have this displayed and perhaps even a tiny speaker as an alarm just in case I don't see there is an alarm condition.

13 June 16
have had a couple of clean compiles but so far all I have been able to do is get a program into a chip but it doesn't run or even oscillate. |O

I am able to upload hex files to the chip and download from the chip. :scared:

Silly question time.
If I downloaded an earlier version than XC8 v1.37 would this help me get all of the required header files etc ?
If so what would be a good version to try?

Do software creators get their jollies by only issuing 3/4 of the header files or something. :-DD

Will pickit3 work with other software other than MPLAB.

Is there free version of Hitec C that won't stop working after 14 days.
There is a full version of the LCD driver I am trying to create as a demo in HiTec but this will no longer compile as HiTec has stopped working after 2 weeks.
I get a clean compile and am able to upload it into a chip but it does nothing.

I have tried to find a simple blinking light program for pic16f84 / mplab, to make sure I am doing everything right, but even they seem to be hard to find.
How the hell does anyone learn this language.
Many sample programs I have found for blinking lights are in assembly. Don't want to try to learn another language at my time of life.

I eagerly await any help I can get.
 :popcorn:
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: LCD PIC16F84 MPLAB
« Reply #1 on: June 13, 2016, 01:23:41 am »
The PIC16F84 was released twenty years ago, back in 1996.  Back when the 'F84 was popular, the available C compilers *SUCKED* and/or were very expensive so most 'F84 sample code is in assembler and, even if written for Microchip MPASM, with 20 years of development in-between, may not even build with the current MPASMX without quite a bit of fiddling.

Not surprisingly, back in 2012, when XC8 v1.00 was first released, Microchip's XC8 compiler team had better things to do than writing demo code for a (then) 16 year old chip.  Instead they wrote code for recently released chips there was still an active marketing budget for. 

However Microchip bought HiTech lock stock and barrel and the core XC8 development team started out as the same people who had been the HiTech C for PIC10/12/16 and for PIC18 team, still has many of the same staff, and XC8 was developed from the HiTech C code-base so there is a very high level of compatibility.  There is a special #define needed to enable compatibility mode with HiTech C for PIC10/12/16 v9.80 or earlier.  Unfortunately documentation for this was dropped, but if your compiler has a folder 'legacy' under the folder 'include', it should still be supported.  Here's what the HiTech C for PIC10/12/16 v9.83 readme had to say about it:
Quote
New header file generation (9.81) Header files in the 9.81 version are now generated from a central database rather than being hand crafted. This may mean that the names of some SFRs or bits within SFRs in the new header files may be different to those in the header files that were previously used by the compiler.
The header files that were previously shipped with the compiler are no longer maintained, but are supplied with this version of the compiler and can be used by defining the macro _LEGACY_HEADERS. Ideally, this macro should be defined using the compiler’s -D option, or in the Define macros field in the Compiler tab of the MPLAB IDE Build Options dialog. If you use a #define to define this, make sure you place this above the line which includes <htc.h>. The legacy include files are located in the legacy directory, inside the include directory of the compiler.
With _LEGACY_HEADERS defined, XC8 will compile *most* older HiTech C code.

A PIC16F84 has to have either an external clock*, or a RC circuit on OSC1 for RC mode or a crystal* + appropriate load caps on OSC1 and OSC2 for LP, XT or HS modes.  If your chip isn't even running, the most probable cause is failure to correctly define the CONFIG word that sets up stuff like oscillator modes.  The next most probable cause is a bad oscillator circuit.

* The clock or crystal must be less than or equal to the PIC's maximum frequency rating (two digits between '-' and '/' in the part no. give frequency in MHz). 
N.B. if your PIC is marked PIC16F84-20/... it is almost certainly fake as Microchip didn't introduce a 20MHz version till the PIC16F84A.  Valid speed codes are -04 and -10.


Microchip recently dropped the legacy PIC18 PLIB from the XC8 install, but that shouldn't affect you as it never supported PIC16.  Its still available as a separate download if you have an old PIC18 project that needs it.

Post the code you are trying to compile (in code tags please!), and the compiler errors from the MPLAB 8 or X output window, then we've got some chance of helping you.
I suggest starting with something simple like a 'hello world' blinky LED program.   Make sure the hardware is adequately documented - either show a schematic or list the exact pin connections in comments in the code.  e.g.:
Code: [Select]
// /MCLR - 10K - Vdd
// OSC1 - (22pF - Vss), - (1) 4MHz Xtal
// OSC2 - (22pF - Vss), - (2)     ''
//
// RB0 - (k) Red LED (a) - 330R - Vdd

Once you have the absolute basics mastered, there is considerable benefit in switching to a more modern PIC.  Many of the newer ones support in-circuit debugging, its considerably easier to find sample code that builds with current tools, and they generally offer far more processing power, memory, and built in peripherals at a lower cost. 
« Last Edit: June 13, 2016, 02:37:17 am by Ian.M »
 

Offline ez24

  • Super Contributor
  • ***
  • Posts: 3082
  • Country: us
  • L.D.A.
Re: LCD PIC16F84 MPLAB
« Reply #2 on: June 13, 2016, 02:04:36 am »
If you are open to other ideas take a look here for material

https://www.eevblog.com/forum/beginners/electronics-primers-course-material-and-books/

and if STM32 is worth looking at

https://leanpub.com/mastering-stm32

I bought this and it currently is at 587 pages at 60% with free updates.  The author is a member here.  The board he uses is less than $20.  There is a sample of the book.

It is not easy to find beginner material on MCUs, 99.999% of the members here are experts  (I am part of the .001 %  |O)



YouTube and Website Electronic Resources ------>  https://www.eevblog.com/forum/other-blog-specific/a/msg1341166/#msg1341166
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: LCD PIC16F84 MPLAB
« Reply #3 on: June 13, 2016, 02:19:56 am »
...or just buy one of the various flavors or Arduino boards and be done with it...
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: us
Re: LCD PIC16F84 MPLAB
« Reply #4 on: June 13, 2016, 03:08:34 am »
It's not clear to me that you've properly install you development environment.
  1)  Install the latest version of MPLAB X
  2)  Install the latest version of XC8 complier

I've been doing all my programming with a PICkit 2.  Recently I bought a PICkit 3 and found that for most 5V PIC chips it doesn't have enough power to drive the PIC.  You need to supply the 5V externally.  I've been using the pic16f877a, pic16f876a and th pic18f2550 without problems.

Your first program should be something simple.  Try to just toggle one bit.  Also, confirm your config bits, oscillator setup, TRIS direction bits and whether your using LAT or PORT for output.  For most chips, you want to use LAT for output and PORT for input.  However, on the pic16f87x chips there is no LAT register and you must use PORT for both input and output.

Post your code please.

 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: us
Re: LCD PIC16F84 MPLAB
« Reply #5 on: June 13, 2016, 03:14:50 am »
Here's a blinking light example.  Make sure you tie MCLR pin high through a 10K resistor.
Code: [Select]
/*
 * File:   main.c
 * Author: Mark
 *
 * Created on June 12, 2016, 11:45 PM
 */

#include <xc.h>
#include <stdint.h>

// CONFIG
#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF       // Watchdog Timer (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (Power-up Timer is enabled)
#pragma config CP = OFF         // Code Protection bit (Code protection disabled)

#define _XTAL_FREQ 10000000L     // 10MHz clock
#define delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))
#define delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))

void main(void) {
   uint8_t led=0;
   
   // Configure I/O pin
   TRISAbits.TRISA0 = 0;   // Select RA0 pin as output

   while (1) {
      PORTAbits.RA0 = led;    // Set I/O bit
      if (++led > 1) led=0;   // Toggle LED value
      delay_ms(500);          // Wait 500ms
   }
}
« Last Edit: June 13, 2016, 04:07:44 am by MarkF »
 
The following users thanked this post: neko efecktz

Offline batteksystem

  • Regular Contributor
  • *
  • Posts: 167
  • Country: hk
    • My ebay store
Re: LCD PIC16F84 MPLAB
« Reply #6 on: June 13, 2016, 05:49:34 am »
Here's a blinking light example.  Make sure you tie MCLR pin high through a 10K resistor.
Code: [Select]
/*
 * File:   main.c
 * Author: Mark
 *
 * Created on June 12, 2016, 11:45 PM
 */

#include <xc.h>
#include <stdint.h>

// CONFIG
#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF       // Watchdog Timer (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (Power-up Timer is enabled)
#pragma config CP = OFF         // Code Protection bit (Code protection disabled)

#define _XTAL_FREQ 10000000L     // 10MHz clock
#define delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))
#define delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))

void main(void) {
   uint8_t led=0;
   
   // Configure I/O pin
   TRISAbits.TRISA0 = 0;   // Select RA0 pin as output

   while (1) {
      PORTAbits.RA0 = led;    // Set I/O bit
      if (++led > 1) led=0;   // Toggle LED value
      delay_ms(500);          // Wait 500ms
   }
}

I would change this to use internal RC Oscillator to avoid any hardware problem with the external crystal circuit.
 
The following users thanked this post: neko efecktz

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: LCD PIC16F84 MPLAB
« Reply #7 on: June 13, 2016, 06:26:57 am »
I would change this to use internal RC Oscillator to avoid any hardware problem with the external crystal circuit.
I may have missed something but the OP says he is using a 16F84

to the OP, if you want it "easier" to begin with, you might want to try MikroC from MikroElektronika. It has a lot of libraries for handling the peripherals and external hardware (for example, there is a library for alphanumeric LCDs). Free to use for ehr.. under 2k of code IIRC

The pickit 3 can be used with the MPLAB X IDE (of course), MPLAB X IPE (to only upload/flash/erase the chip memory), MPLAB 8. I'm not sure about other software to control it, so for example, you write your code into mikroc, compile, then open the ipe and flash the chip.

Perople who learn this try not to use a 20 year old chip :) but even if they do, they read the datasheet as everything is in there. especially for these old parts that have little more than the core, the IOs and a couple of timers you can read the datasheet back to back in 30 minutes or less

People who fail at this usually go grab an arduino.. or go back at it
 
The following users thanked this post: neko efecktz

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: LCD PIC16F84 MPLAB
« Reply #8 on: June 13, 2016, 07:25:00 am »
THANKYOU EVERYONE FOR YOUR HELP
THE ONLY REASON I AM USING THE PIC16F84 IS I HAPPENED TO HAVE THEM BOUGHT IN A BULK LOT OF COMPONENTS FROM A SHOP THAT WAS CLOSING DOWN.
TURNS OUT THE SPECK SHEET THAT CAME WITH THEM WAS WRONG
IT STATED PIC16F84-20
THEY ARE (GETS OUT MAGNIFYING GLASS AND WETS THE CHIP, TURNS TO THE RIGHT ANGLE TO CATCH THE LIGHT) PIC 16F84A-20/P

I MANAGED TO GET A FLASHING LED GOING FROM THE CODE UPLOADED BY MARKF
ON THE FIRST ATTEMPT IT WOULDN'T WORK.
CHECKED THE LAYOUT AND FOUND THE LED BACK TO FRONT.
STILL DIDN'T WORK
I HAD A CRAZY IDEA.  WHAT IF IS MY BREADBOARD.
BRAND NEW BUT YOU NEVER KNOW.
REBUILT IT ON ONE I'VE HAD FOR OVER 30 YEARS
BINGO, ONE BLINKING LED.

2 BRAND NEW BREADBOARDS FROM CHINA WORTHLESS.
LESSONS LEARNED NOT TO TRUST BREADBOARDS FROM CHINA, PRICELESS.

I WILL DRAG OUT A LARGER DOUBLE BREADBOARD THAT STILL HAS AN OLD GUITAR EFFECT PROJECT ON IT FROM A COUPLE OF YEARS AGO
REBUILD THE LCD PROJECT AND HOPEFULLY MAY GET SOMEWHERE.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: LCD PIC16F84 MPLAB
« Reply #9 on: June 13, 2016, 07:53:08 am »
Athough the PIC16F84A is 100% binary code compatible with the PIC16F84, there are some subtle differences in the programming algorithm, so it is critically important that you have the correct PIC selected in MPLAB.

If you have problems building the LCD demo, post the code (in code tags or a link to it if its already on the WWW) and the error messages you are getting.

If you've got questionable solderless breadboards it is always worth powering off and double-checking continuity for any suspect pins between the chip or other component pin and a wire inserted in a spare hole in the same strip using a DMM.   Beware of longer breadboards that have the power rails at the long edges split into two sections, each half the length of the board!
 

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: LCD PIC16F84 MPLAB
« Reply #10 on: June 13, 2016, 12:24:50 pm »
GIDDAY IAN     PLEASE EXCUSE THE CAPS, NOT SHOUTING, JUST A LAZY TYPIST BUT I TRY TO MAKE SURE THAT THE CODE IS CORRECT..
HAVE BUILT UP THE PROJECT ON THE OLD BREAD BOARD BUT IT STILL ISN'T WORKING.
THE DISPLAY IS BLANK AND I SUSPECT THE OSCILLATOR IS ALSO POT WORKING.
THE CODE IS THE ONE I FOUND IN THE HITECH DEMOS.
I HAD TO CHANGE THE PORT DETAILS TO SUIT THE PIC16F84A AND I'M SURE I GOT IT ALL.
I WILL HAVE ANOTHER GO TOMORROW MORNING AND IF UNSUCCESSFUL WILL UPLOAD THE CODE AND ANOTHER ONE THAT IS SUPPOSED TO BE MPLAB, IF I CAN FIND IT.
I'M A SHIFT WORKER 2:30pm TILL 12:20am SO YOU MAY NOT HEAR FROM ME UNTIL WEDNESDAY.
PUBLIC HOLIDAY HERE IN AUSTRALIA TODAY.

HOW DO I SET UP A CODE TAG?
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: LCD PIC16F84 MPLAB
« Reply #11 on: June 13, 2016, 12:34:02 pm »
[ code ] insert code here [ /code ]

but without the spaces between brackets it becomes this
Code: [Select]
insert code here
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: LCD PIC16F84 MPLAB
« Reply #12 on: June 13, 2016, 03:35:07 pm »
GIDDAY IAN     PLEASE EXCUSE THE CAPS, NOT SHOUTING, JUST A LAZY TYPIST BUT I TRY TO MAKE SURE THAT THE CODE IS CORRECT..
Its taken you two weeks to get your questions an active audience, so don't make your posts harder to read, lest your audience deserts you.   Unjam your Caps Lock key.  C is case sensitive, so are we . . . . .

How To Ask Questions The Smart Way
 

Offline ez24

  • Super Contributor
  • ***
  • Posts: 3082
  • Country: us
  • L.D.A.
Re: LCD PIC16F84 MPLAB
« Reply #13 on: June 13, 2016, 05:21:59 pm »
GIDDAY IAN     PLEASE EXCUSE THE CAPS, NOT SHOUTING, JUST A LAZY TYPIST BUT I TRY TO MAKE SURE THAT THE CODE IS CORRECT..
HAVE BUILT UP THE PROJECT ON THE OLD BREAD BOARD BUT IT STILL ISN'T WORKING.
THE DISPLAY IS BLANK AND I SUSPECT THE OSCILLATOR IS ALSO POT WORKING.
THE CODE IS THE ONE I FOUND IN THE HITECH DEMOS.
I HAD TO CHANGE THE PORT DETAILS TO SUIT THE PIC16F84A AND I'M SURE I GOT IT ALL.
I WILL HAVE ANOTHER GO TOMORROW MORNING AND IF UNSUCCESSFUL WILL UPLOAD THE CODE AND ANOTHER ONE THAT IS SUPPOSED TO BE MPLAB, IF I CAN FIND IT.
I'M A SHIFT WORKER 2:30pm TILL 12:20am SO YOU MAY NOT HEAR FROM ME UNTIL WEDNESDAY.
PUBLIC HOLIDAY HERE IN AUSTRALIA TODAY.

HOW DO I SET UP A CODE TAG?

Too hard to read
YouTube and Website Electronic Resources ------>  https://www.eevblog.com/forum/other-blog-specific/a/msg1341166/#msg1341166
 

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: LCD PIC16F84 MPLAB
« Reply #14 on: June 13, 2016, 10:43:35 pm »
Gidday Ian,  sorry about the caps
I Have built up the project on the old bread board but it still isn't working.
The display is blank and I suspect the oscillator is also not working.
The code is the one I found in the Hitech demos.
I had to change the port details to suit the PIC16F84A and I'm sure I got it all.
There are a lot of #include  which lead to more #include
I will have another go tomorrow morning and if unsuccessful will upload the code and another one that is supposed to be Mplab, if I can find it.
I'm a shift worker 2:30pm till 12:30am so you may not hear from me until Wednesday.

How do I set up a code tag?

thankyou
Bill
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: LCD PIC16F84 MPLAB
« Reply #15 on: June 13, 2016, 11:05:16 pm »
The display is blank and I suspect the oscillator is also not working.
  Only one way to find out...measure it.
Start with a blinky LED and go from there.
If you can't make a blinky LED, you sure can't go much farther...

Quote
How do I set up a code tag?
See reply #11.
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: LCD PIC16F84 MPLAB
« Reply #16 on: June 13, 2016, 11:12:02 pm »
Was the LCD code bundled with the HiTech C install (if so, which version) or did you find it on the web?   I'd add a LED on a spare pin, and a function to flash it once, say 200ms On, 300ms Off.  Call the LED flash at the beginning of main() and after every LCD function that main() calls.   You'll soon see if its running at all or getting hung up somewhere just by counting flashes.

If you are using the full forum editor (not the quick reply) simply click the button which insert an empty pair of code tags for you then copy/paste your source code where it left your cursor, between ][.  You can also attach the source file as this forum accepts .c and .h files.  For larger programs, and more obscure bugs it can be helpful to package the project (as a .zip file) from within MPLAB and attach that so that all MPLAB/XC8 users here can build your project, but as we then have to unzip the project before we can look at the source, its less appropriate for quick questions.   Often the best bet is to post the function or section of the code you are asking about in code tags with the full source attached either as individual .c and .h files for a small project or as a packaged project .zip file for larger multi-file projects.
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: us
Re: LCD PIC16F84 MPLAB
« Reply #17 on: June 14, 2016, 01:09:56 am »
Here's a blinking light example.  Make sure you tie MCLR pin high through a 10K resistor.
. . .

I would change this to use internal RC Oscillator to avoid any hardware problem with the external crystal circuit.

I don't use a crystal.  I always use a Standard Clock Oscillator.

neko efecktz:
The pic16f84 doesn't have any analog inputs.  At a minimum, you will want a PIC with analog inputs and create a voltage divider with 2 resistors to limit the PIC input to 0-5 volts from whatever the power supply voltage is.
« Last Edit: June 14, 2016, 01:15:17 am by MarkF »
 

Offline batteksystem

  • Regular Contributor
  • *
  • Posts: 167
  • Country: hk
    • My ebay store
Re: LCD PIC16F84 MPLAB
« Reply #18 on: June 14, 2016, 01:17:15 am »
Here's a blinking light example.  Make sure you tie MCLR pin high through a 10K resistor.
. . .

I would change this to use internal RC Oscillator to avoid any hardware problem with the external crystal circuit.

I don't use a crystal.  I always use a Standard Clock Oscillator.

neko efecktz:
The pic16f84 doesn't have any analog inputs.  At a minimum, you will want a PIC with analog inputs and create a voltage divider with 2 resistors to limit the PIC input to 0-5 volts from whatever the power supply voltage is.

That's my experience back in my university days (when I was a tutor for the electronics class >10 years ago). We were teaching with PIC18F452, and some of the frequent advice I made to student is to simplify their code to get the LED blinking. This help them troubleshoot a lot of boards, especially for those who made their PCB for the first time. They can always make the crystal circuit right later for the RS-485 or whatever frequency counting applications they required later, confirm the errors first.

Offline CJay

  • Super Contributor
  • ***
  • Posts: 4136
  • Country: gb
Re: LCD PIC16F84 MPLAB
« Reply #19 on: June 14, 2016, 10:27:52 am »
Basically, what all the rest of the replies have said, get a basic circuit working first, doesn't matter if you write the code or not, just make sure your hardware works.

But, my opinion, for a beginner who is new to the IDE, new to the programmer, new to the hardware, I would always recommend buying a built dev board of some description, it removes so much of the doubt when you have one definite, it's a handy sanity check.

Microchip have some cute little demo boards intended to be used with PICKit3 and they're not too expensive (they're not cheap compared to some) considering you can rely on them to work out of the box (they usually come with demo code to chase or blink LEDs programmed into them)

I'd also recommend ditching the 'F84 and getting something that's got much better support for debugging, C and the newer libraries but whatever you choose will have many more peripherals so it will require more 'setting up' in code to make the ports do sensible things.
 

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: LCD PIC16F84 MPLAB
« Reply #20 on: June 14, 2016, 11:43:31 pm »
15 JUNE 16
Hello all,
Thank you for your responses regarding my problem.
Thank you MarkF for your code.
Ian.M asked for the Hi-Tech code I've been trying to use.
I am attempting to link in a RAR file of the original project folder supplied with hi-tech version 9.60
I have also included the mplab project folder I have created.
There are as few places I have had to change the ports from portd to portb
And    ADCON1 = 0x06;   // Disable analog pins on PORTA

.rar file was disallowed trying to find out what compressed file types are allowed.
I am sending a zip file instead.
Tried to send the file yesterdays but I didn't get to as I had to go to work.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: LCD PIC16F84 MPLAB
« Reply #21 on: June 15, 2016, 12:13:56 am »
The PIC16F84A doesn't have an ADCON1 SFR.  Delay routines from HiTech C for PIC10/12/16 v9.65 or earlier that don't use the _delay() psuedofunction aren't to be trusted under HiTech C for PIC10/12/16 v9.81 or later or any version of XC8.

Also I cant see the PIC's CONFIG setting anywhere in the source.  Without proper CONFIG settings the 'F84A will default to external RC oscillator with the WDT enabled which will either result in it not running or repeatedly resetting.
« Last Edit: June 15, 2016, 02:08:19 am by Ian.M »
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: LCD PIC16F84 MPLAB
« Reply #22 on: June 15, 2016, 12:58:45 am »
Time must be worth nothing.
Could've bought some sort of cheap Arduino knockoff and been miles and miles ahead of the game by now...in only a couple of weeks.
As much as I love my PICs and straight assembly programming for those PICs, I've all but switched camps.  Haven't looked back and got more done in far less time since doing so.
Got a bunch of PICs that'll be going on ebay sooner or later too.
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline neko efecktzTopic starter

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: LCD PIC16F84 MPLAB
« Reply #23 on: June 15, 2016, 01:12:39 am »
EUREKA...
It's working
Thank you so much.
I just pasted the code sent by MarkF I think it was into main.c..
once again I'd like to thank everyone for their help.

I may start to look at Arduino or Cherry pi in the future but then that's another code to learn, bu isn't that what life's for

All The Best.
BILL.

// CONFIG
#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF       // Watchdog Timer (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (Power-up Timer is enabled)
#pragma config CP = OFF         // Code Protection bit (Code protection disabled)

#define _XTAL_FREQ 10000000L     // 10MHz clock
#define delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))
#define delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: LCD PIC16F84 MPLAB
« Reply #24 on: June 15, 2016, 02:13:45 am »
[quote author=neko efecktz link=topic=69626.msg962290#msg962290 date=1465953159
I may start to look at Arduino or Cherry pi in the future but then that's another code to learn, bu isn't that what life's for
[/quote]
True, but whatever code you'D write with the Arduino IDE is a helluva lot more human readable than the mess required to keep anything in the PIC world happy.
I only know what it is because I've been using it for almost a couple decades.  If I had to do it again, it would be via an Arduino type of thing.
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf