PDA

View Full Version : I've done it again



karenhornby
- 9th April 2008, 17:09
I've been through the searches trying to find the answer to this, and have also googled it as well as trying to read the manual
I'm trying to get an LCD to display something if both port C.1 AND port C.2 are high, but display something different if the ports are low
my code is
IF PORTC.1 = 0 AND PORT C.2 = 0 then lcdout $FE,1,"test 1"
If PORTC.1 = 1 AND PORT C.2 = 1 then LCDOUT $FE,1,"Test 2"
I've tried all the usual by trying
IF (PORTC.1 = 0) AND (PORT C.2 = 0) then lcdout $FE,1,"test 1"
If (PORTC.1 = 1) AND (PORT C.2 = 1) then LCDOUT $FE,1,"Test 2"and various other combinations
Promise I'll try not to ask stupid questions again (for today anyway :) )
Forgot to say I'm using PBPro 2.5 and Microcode Studio to assemble it, and Picflash to program, by the way I still cant find any way of setting OSC to HS I've tried various suggestions, and read the thread http://www.picbasic.co.uk/forum/showthread.php?t=543 but none work, I'm guessing its something to do with the rubbish Picflash program I'm using?

JD123
- 9th April 2008, 17:13
remove the space in the "port c.2"

mister_e
- 9th April 2008, 17:13
Some PIC may have ADCs or else fancy multiplexed stuff on this port. You want to make sure they're disabled first, unless you will have some erratic results.

I usually use something a little bit different


PORTC21Value=PORTC & 3

IF PORTC21 =1 then ...
if PORTC21=2 then ...
IF PORTC21=3 then ...


This read the whole PORT in oneshot and may override some RMW issue.

Make sure you have any kind of pull-up / down resistor in case you're reading PushButtons
<hr>
There's nothing bad with PicFlash. You need to set your config fuses in your code and when you import the .HEX file, it will import/change the Config Fuses for you.

You can lauch PICFlash in MCS. You need to add a programmer in the list. View>>Compile and program option>> programmer and folllow the instructions.

I use the following parameters line

-pPIC$target-device$ -f$hex-filename$ -e -w
HTH

karenhornby
- 9th April 2008, 17:19
remove the space in the "port c.2"

I should have been born a Blonde!
Cant believe I'be been so stupid not to spot that
Thanks :)

BTW Tried solving the HS problem too by using @_config OSC_HS It assembles fine, but changed nothing when Picflash is run, Oscillator XT is still selected

mister_e
- 9th April 2008, 17:23
because you're using PM to compile. use

@ device pic16F877A, hs_osc, wdt_on, lvp_off, protect_off

karenhornby
- 9th April 2008, 17:27
because you're using PM to compile. use

@ device pic16F877A, hs_osc, wdt_on, lvp_off, protect_off

Nope wont take it, comes up with WARNING 207 found label after colum 1.(device)
and Error 122 illegal opcode (pic16f877A)
BTW Tried
-pPIC$target-device$ -f$hex-filename$ -e -w but it just wont auto program with Picflash even when I put those paramaters in., does it manually fine but still have to change the XT to HS

mister_e
- 9th April 2008, 17:31
@ __CONFIG _HS_OSC & _LVP_OFF

You must make sure you PGM jumper settings are right too.

karenhornby
- 9th April 2008, 18:26
You must make sure you PGM jumper settings are right too.

Umm not to appear TOO blonde, but what Jumper settings?
I'm using this easypic5 development board, with the Picflash programmer software and Microcode Studio version 3.0.0.5

All I do is plug the USB cable into the board and program the chip?

mister_e
- 9th April 2008, 19:03
:D I don't have the EasyPIC 5... but his ol' version 4

let's see the programming jumper in the following PDF

http://www.mikroe.com/pdf/easypic5/easypic5_manual.pdf

look at page 12. PIC16F877A use RB5 for PGM, your jumper group (J10) must be set exactly as they show.

and then you also have to make sure the Socket Selection one are also properly set. PDF page 13, figure 12.

Next.. figure 14... MCLR as RESET.

Next.. figure 15 OSC jumpers

now you can also set your Pull-up/Down resistor with with your dip switches and jumper located on the right of your board.

karenhornby
- 9th April 2008, 19:22
OMG Your a star :)
It now programs as well as compiles and i dont have to start Picflash manually
However I've still got the problem of trying to set hs_oscThe only way I can set it is manually with the picflash program, I cant find any way they Microcode studio will let me set it in the program

mister_e
- 9th April 2008, 19:27
i suspect you have an overwrite error message?

read again the thread i suggested.. post 5

http://www.picbasic.co.uk/forum/showthread.php?t=543

mister_e
- 9th April 2008, 19:31
euh, just to make sure of everything... notice the few spaces i've added between @ and __CONFIG...

karenhornby
- 9th April 2008, 19:57
euh, just to make sure of everything... notice the few spaces i've added between @ and __CONFIG...

Yep copied and pasted it to eliminate errors in my typing

However your right, its coming up with Error[118] Overwriting previous address contents (2007)

Acetronics2
- 9th April 2008, 20:32
Hi, Steve

Error 118 comes when using MPASM ( lower part of screen ) ... NOT PM ...

So, config lines still have to be commented in the .inc files ...

I just have set µCode here ...

Seems Karen uses MPASM ...

Alain

mister_e
- 9th April 2008, 20:39
Hence why i'd suggested to notice the space betwen @ and __CONFIG, the overwrite error message, and post #5 in the FAQ?

'Stie d'franssā a marde :D

mackrackit
- 9th April 2008, 20:57
My two cents.

karenhornby,
Steve use to have in his signature something to the effect.

"There are no problems, only learning opportunities"

Do not worry about what may seem like a stupid question.
We all have/had/will ask them :)

karenhornby
- 9th April 2008, 21:12
Your all stars :)
mister_e Sorry, I know you gave me the answer a couple of times, but I just couldn't get it for ages, tbh I actually never knew there were include files in the PBP folder duh!
But I'm learning fast :)

Thanks all

now to the next problem..... lol
to do with LCD scrolling., however I'll post the question in Darrel Taylor's thread about that