|
|
View previous topic :: View next topic |
Author |
Message |
trento
Joined: 14 Oct 2005 Posts: 26
|
no output |
Posted: Fri Nov 04, 2005 2:17 am |
|
|
Hi dear all plz help me to solve this problem with my program
when I download the program to PIC(16F877A)an I check the output by osscilscope there is no output. please tell me what is the wrong.
please i need help
Code: |
#include <16F877A.h>
#FUSES HS,NOWDT,NOPROTECT,NOPUT
#USE DELAY( CLOCK=20000000 )
#USE FAST_IO(B)
#USE FAST_IO(D)
#byte port_b=6
#byte port_d=8
static byte CONST UP_MAP0[8] = { 0xe1,0xc3,0x87,0x0f,0x1e,0x3c,0x78,0xf0 };
\\ this start with RB0 to be on first and finish with Rb3 and this will be done by the for(cnt <4) loop AND the second half is complement which mean the first pin switch on will be the first one switch off AND WILL BE DONE BY FOR(tnt < 8) loop and by these way the PIC will generate a signal with different delay betwean each other
static byte CONST UP_MAP1[8] = { 0xd2,0x96,0x1e,0x0f,0x2d,0x69,0xe1,0xf0 };
\\ this start with RB1 to be on first and finish with Rb0 the second half is complement which mean the first pin switch on will be the first one switch off
static byte CONST UP_MAP2[8] = { 0xb4,0x3c,0x2d,0x0f,0x4b,0xc3,0xd2,0xf0 };
\\ this start with RB2 to be on first and finish with Rb1 the second half is complement which mean the first pin switch on will be the first one switch off
static byte CONST UP_MAP3[8] = { 0x78,0x69,0x4b,0x0f,0x87,0x96,0xb4,0xf0 };
\\ this start with RB3to be on first and finish with Rb2 the second half is complement which mean the first pin switch on will be the first one switch off
\\ this is different arrangment inside the matrix for port b and port D
main(){
char cnt,tnt;
\\ i use the varaible tnt to choose between the two different matrix which mean two arrangment the arrangement of the port pins on stage
set_tris_b(0);
set_tris_d(0);
tnt = 0 ;
port_b = 0xf0,
port_d = 0xf0;
for(;;) {
for (tnt=0 ; tnt < 2 ; tnt++) {
delay_us(366);
for (cnt=0 ; cnt < 4 ; cnt++) {
switch (tnt) {
\\ this switch statment i use to choose between two arrangmet for turning on the pin from the matrix
case 0:
port_b = UP_MAP0[cnt];
break;
case 1:
port_b = UP_MAP2[cnt];
break;
}
switch (cnt) {
\\ this switch stament to make delay between the pin
\\ this program divided to 4 loop the 0------>4 loop to turn on the portB and portd respitivly and
\\ the loop 4------->8 FOR turn off port b and port d respictivly
by this way i generate square wave with 50 HZ as frequency with different delay
case 0:
delay_us(1146);
break;
case 1:
delay_us(999);
break;
case 2:
delay_us(951);
break;
case 3:
delay_us(3076);
break; }
}
for( cnt=0 ; cnt < 4 ; cnt++ ){
switch (tnt) {
case 0:
port_d = UP_MAP0[cnt];
break;
case 1:
port_d = UP_MAP2[cnt];
break;
}
switch (cnt) {
case 0:
delay_us(951);
break;
case 1:
delay_us(999);
break;
case 2:
delay_us(1146);
break;
case 3:
delay_us(366);
break;}
}
for (cnt=4 ; cnt < 8 ; cnt++) {
switch (tnt) {
case 0:
port_b = UP_MAP1[cnt];
break;
case 1:
port_b = UP_MAP3[cnt];
break;
}
DELAY_US(366);
switch (cnt) {
case 4:
delay_us(1146);
break;
case 5:
delay_us(999);
break;
case 6:
delay_us(951);
break;
case 7:
delay_us(3076);
break;
}
}
for (cnt=4 ;cnt < 8; cnt++){
switch (tnt) {
case 0:
port_d = UP_MAP1[cnt];
break;
case 1:
port_d = UP_MAP3[cnt];
break;
}
switch (cnt) {
case 4:
delay_us(951);
break;
case 5:
delay_us(999);
break;
case 6:
delay_us(1146);
break;
case 7:
delay_us(366);
break; }
} } } }
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Nov 04, 2005 9:27 am |
|
|
Quote: | I check the output by osscilscope there is no output.
please tell me what is the wrong. |
Make the change shown in bold below:
Quote: |
#include <16F877A.h>
#FUSES HS,NOWDT,NOPROTECT,NOPUT, NOLVP
#USE DELAY( CLOCK=20000000 ) |
Also, please don't double-space your code, when you post it. |
|
|
trento
Joined: 14 Oct 2005 Posts: 26
|
|
Posted: Fri Nov 04, 2005 11:23 pm |
|
|
Hi dear sir and thank you for your help I do as you said but there is no output
regards |
|
|
Sherpa doug Guest
|
|
Posted: Sat Nov 05, 2005 8:35 am |
|
|
How about trying a simple Hello World program?
Try something like:
<Headers for your chip, crystal, and IO pins>
Main()
{
while (true)
putc('Hello World \n\r');
}
Try to get it small eough so that it all fits on your screen at once. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sat Nov 05, 2005 8:35 am |
|
|
First:
As PCM said above, please stop double and triple spacing your code! I believe you have been told this before more than once. If you persist no one is going to be willing to help you. No one here wants to waste thier valuable time straightening out your formatting to even be able to read the code.
Second:
// This code will not even
// compile because your
// comment marks are
// backwards. I do not
// see how you could have
// compiled and run it as
// posted.
And Finally:
You have a hardware problem. Once I fixed the backward comments, added NOLVP as indicated as PCM told you and properly formatted your code it compiled and ran. The Port B pins toggled as they should ( I don't happen have port D connected right now). |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|