|
|
View previous topic :: View next topic |
Author |
Message |
Secersh
Joined: 19 Oct 2009 Posts: 8 Location: Serbia, Belgrade
|
PIC16F84 help!!!! |
Posted: Mon Oct 19, 2009 6:46 pm |
|
|
Hi everybody, I need some help with this project, and I think this is the right place to come to. This is the first time I use the CCS, and this is my first program in it. I tested it in Real PIC Simulator, but it seems not to be working. Here is the code:
Code: |
#include <16f84.h>
#include <stdio.h>
#define Ld1 ra0
#define Ld2 ra1
#define Start_btn ra2
#define Add_btn ra3
#define Relay ra4
#define Beep rb0
#use delay( clock=4000000 )
#fuses XT,NOWDT,NOPROTECT,NOPUT
byte const Display[10] ={0xDE,0x06,0xB6,0xAE,0x66,0xED,0xFC,0x86,0xFE,0xEE};
void main(void)
{
int Vreme=0,b,i,temp,temp0,c1,c2,t;
set_tris_a (0x06);
set_tris_b (0x00);
port_a = 0x0C;
port_b = 0xDE;
Loop: while(!Add_btn){
for(b=0;b<=416;b++){
Beep = true;
delay_us(300);
Beep = false;
delay_us(300);
}
Vreme++;}
temp0 = Vreme;
c2 = temp%10;
temp/=10;
c1 = temp%10;
port_b = Display[c1];
Ld1 = true;
delay_ms(100);
Ld1 = false;
port_b = Display[c2];
Ld2 = true;
delay_ms(100);
Ld2 = false;
while(!Start_btn){
for(b=0;b<=416;b++)
Beep = true;
delay_us(300);
Beep = false;
delay_us(300);}
Relay = true;
for(i=Vreme;i<=0;i--){
temp = i;
c2 = temp%10;
temp/=10;
c1 = temp%10;
for(t=0;t<=300;t++){
port_b = Display[c1];
Ld1 = true;
delay_ms(100);
Ld1 = false;
port_b = Display[c2];
Ld2 = true;
delay_ms(100);
Ld2 = false;
}
}
if (i==0)
Relay = false;
goto Loop;
}
|
Please help!!! thx... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 19, 2009 7:51 pm |
|
|
Quote: | void main(void)
{
int Vreme=0,b,i,temp,temp0,c1,c2,t;
Loop: while(!Add_btn){
for(b=0;b<=416;b++){
Beep = true;
while(!Start_btn){
for(b=0;b<=416;b++)
Beep = true;
for(t=0;t<=300;t++){
port_b = Display[c1];
Ld1 = true;
delay_ms |
In CCS, an 'int' is an unsigned 8-bit integer. It can only go from 0 to 255.
If you need a larger value, then use 'int16'. In the code above, 'b' and 't'
should be declared as 'int16'
If you need a signed value, then put 'signed' in front of the declaration.
This is all explained in the CCS manual. |
|
|
Secersh
Joined: 19 Oct 2009 Posts: 8 Location: Serbia, Belgrade
|
|
Posted: Tue Oct 20, 2009 5:33 am |
|
|
Thanks, it seems to fix the ccs code, but still not working in Real Pic Simulator... |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Tue Oct 20, 2009 5:42 am |
|
|
#define Ld1 ra0
#define Ld2 ra1
#define Start_btn ra2
#define Add_btn ra3
#define Relay ra4
#define Beep rb0
What are ra0, ra1, ra2, ra3, ra4, rb0 and where are they defined ?
I assume they are suppose to be port pins. |
|
|
Secersh
Joined: 19 Oct 2009 Posts: 8 Location: Serbia, Belgrade
|
|
Posted: Tue Oct 20, 2009 5:46 am |
|
|
Yes, they are defined in pic16f84.h, but i'm not sure does it work like this #byte port_a=0x05
#bit ra4 =0x05.4
????? |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
whose header R U using ????? |
Posted: Tue Oct 20, 2009 6:07 am |
|
|
my 16f84.h file has no def for ra0 etc
and your code won't compile.
where did you get your header with this set of nonsense defs?
i think you mean PIN_A0 PIN_A1 etc
i'd try for a start looking in the CCS header files
and using THOSE defs
just a comment - simulators are just swell if you never plan to make a working device/system - but the real test is BUILDING it and trying with actual hardware.
but before any of that it has to at least compile.
your code does NOT - at least under CCS |
|
|
Secersh
Joined: 19 Oct 2009 Posts: 8 Location: Serbia, Belgrade
|
|
Posted: Tue Oct 20, 2009 6:15 am |
|
|
I'm not sure is it header from ccs, when I opened it I found ra0, ra1 etc.
I'll try it with some other header, that have PIN_A0...thx |
|
|
Secersh
Joined: 19 Oct 2009 Posts: 8 Location: Serbia, Belgrade
|
|
Posted: Tue Oct 20, 2009 6:52 am |
|
|
Manual say it all..........
Thank you all!!! |
|
|
|
|
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
|