View previous topic :: View next topic |
Author |
Message |
Marcin Guest
|
Problem with 16f877a and 16f876a. |
Posted: Wed Apr 16, 2003 5:54 am |
|
|
Hello!!!
When I try to send simple ir-codes on 16f877a or 16f876a it isn't working, but when I'm using the same program in other Pic (ex. 16f870 or 16f84a) it's working perfectly. This problem exist also, when I'm trying to send something via Rs232 but on 16f84a it works good.
Here you have a listing.
#include <16F84A.H>
#fuses HS,NOPROTECT,NOWDT
#use delay(clock=12000000)
#define BUT1 PIN_B2
#define BUT2 PIN_B3
#DEFINE RED_LED PIN_A1
#DEFINE IR_LED PIN_A0
#define IR_ON output_high(IR_LED)
#define IR_OFF output_low(IR_LED)
#define RED_ON output_high(RED_LED)
#define RED_OFF output_low(RED_LED)
or
#include <16F876A.H>
#fuses HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP
#use delay(clock=12000000)
#define BUT1 PIN_B4
#define BUT2 PIN_B5
#DEFINE RED_LED PIN_B1
#DEFINE IR_LED PIN_B2
#define IR_ON output_high(IR_LED)
#define IR_OFF output_low(IR_LED)
#define RED_ON output_high(RED_LED)
#define RED_OFF output_low(RED_LED)
pulse()
{
output_high(RED_LED);
delay_ms(100);
output_low(RED_LED);
}
void pulse_40(int16 pulses) // 0,25 us
{
while (pulses--)
{
IR_ON;
delay_us(12);
delay_cycles(2);
IR_OFF;
delay_us(12);
}
}
send_nec80(int32 c)
{
int i;
pulse_40(317);
delay_us(4200);
for (i=0;i<=32;i++)
{
if(bit_test(c,31))
{
pulse_40(18);
delay_us(1650);
}
else
{
pulse_40(18);
delay_us(550);
}
c<<=1;
}
pulse();
}
main()
{
delay_ms(200);
pulse();
while(1)
{
if (input(BUT1)==0) send_nec80(0x61D6708F);
if (input(BUT2)==0) send_nec80(0x61D68800);
}
}
I will be gratefull for your help.
Marcin
___________________________
This message was ported from CCS's old forum
Original Post ID: 13704 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Problem with 16f877a and 16f876a. |
Posted: Wed Apr 16, 2003 12:33 pm |
|
|
:=Hello!!!
:=When I try to send simple ir-codes on 16f877a or 16f876a it isn't working, but when I'm using the same program in other Pic (ex. 16f870 or 16f84a) it's working perfectly. This problem exist also, when I'm trying to send something via Rs232 but on 16f84a it works good.
:=
:=#fuses HS,NOPROTECT,NOWDT
:=#define BUT2 PIN_B3
------------------------------------------------------------
The most likely solution is that you need to add NOLVP to the
end of the #fuses statement, for the 16F87x PICs. Example:
#fuses HS,NOPROTECT,NOWDT,NOLVP
___________________________
This message was ported from CCS's old forum
Original Post ID: 13714 |
|
![](templates/subSilver/images/spacer.gif) |
Marcin Guest
|
Problem with 16f877a and 16f876a. |
Posted: Wed Apr 16, 2003 2:57 pm |
|
|
Even when I'm using NOLVP on the end of #fuses it doesn't work. But when I write other program (ex. NOKIA-LCD via SPI or reactive IR-codes) problem doesn't exist.
Thanks for your help.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13723 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Problem with 16f877a and 16f876a. |
Posted: Wed Apr 16, 2003 10:53 pm |
|
|
:=Even when I'm using NOLVP on the end of #fuses it doesn't work. But when I write other program (ex. NOKIA-LCD via SPI or reactive IR-codes) problem doesn't exist.
---------------------------------------------
1. So you're saying that the 16F877A only fails with the
program that you posted ? It works OK with the two other
programs you listed above ?
2. What's your version of the compiler ? If you post the
version, I'll try to install that version and compile your
sample code. Then I'll check the .LST file to see if there
is a problem.
3. I know that the 16F877A requires a different method of
writing to program memory, and not all versions of the compiler
support the new method. So does your program try to write to
program memory ?
4. What programmer are you using for the 16F877A ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 13743 |
|
![](templates/subSilver/images/spacer.gif) |
Marcin Guest
|
Problem with 16f877a and 16f876a. |
Posted: Thu Apr 17, 2003 3:02 am |
|
|
<font face="Courier New" size=-1>I'm using ccs v3.091
MPlab 5.20.00
JDM programmer + ICProg 1.05A
Thanks</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13749 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Problem with 16f877a and 16f876a. |
Posted: Thu Apr 17, 2003 1:38 pm |
|
|
:=<font face="Courier New" size=-1>I'm using ccs v3.091
:=MPlab 5.20.00
:=JDM programmer + ICProg 1.05A
:=Thanks</font>
------------------------------------------
I compiled your program with PCM vs. 3.091 and 3.148.
The only differences I noticed were in the start-up code.
The differences only appear to affect the ADCON and ADCON1
registers. So I'm not sure if that would cause a problem
for you. I don't have a 16F877A chip to test. So I'm not
sure if I can help you much more on this. It possibly could
be a programmer problem. I read the web boards on the IC prog
program, and they say your version should support the 'A'
version of the PICs.
I read the two errata sheets on the 16F87xA, available here:
<a href="http://www.microchip.com/download/lit/suppdoc/errata/80128d.pdf" TARGET="_blank">http://www.microchip.com/download/lit/suppdoc/errata/80128d.pdf</a>
and here:
<a href="http://www.microchip.com/download/lit/suppdoc/errata/80133d.pdf" TARGET="_blank">http://www.microchip.com/download/lit/suppdoc/errata/80133d.pdf</a>
It seems that an early version of the chips had a serious
problem and could not run reliably above 4 MHz. Is it possible
that you have this early version of the silicon ?
Since I don't have a chip to test, this is probably all the
help I can give you.
Here's the start-up code inserted by the compiler for vs. 3.091:
<PRE>
0000 00417 ........ main()
0000 00418 ........ {
0083 0184 00419 CLRF 04
0084 301F 00420 MOVLW 1F
0085 0583 00421 ANDWF 03,F
0086 300F 00422 MOVLW 0F
0087 1683 00423 BSF 03.5
0088 009F 00424 MOVWF 1F
0089 1283 00425 BCF 03.5
0000 00426 ....................
</PRE>
Here's the start-up code produced by vs. 3.148:
<PRE>
0000 00436 ....... main()
0000 00437 ....... {
0082 0184 00438 CLRF 04
0083 301F 00439 MOVLW 1F
0084 0583 00440 ANDWF 03,F
0085 3007 00441 MOVLW 07
0086 1683 00442 BSF 03.5
0087 009F 00443 MOVWF 1F
0088 3007 00444 MOVLW 07
0089 1283 00445 BCF 03.5
008A 009F 00446 MOVWF 1F
</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13769 |
|
![](templates/subSilver/images/spacer.gif) |
Marcin Guest
|
Problem with 16f877a and 16f876a. |
Posted: Thu Apr 17, 2003 4:14 pm |
|
|
Thank you for your advises.I will read it.
Marcin
___________________________
This message was ported from CCS's old forum
Original Post ID: 13781 |
|
![](templates/subSilver/images/spacer.gif) |
|