manoj madhavan
Banned
- Joined
- May 1, 2010
- Messages
- 119
- Helped
- 5
- Reputation
- 10
- Reaction score
- 5
- Trophy points
- 1,308
- Location
- India, Kerala, Moolamattom
- Activity points
- 0
// PIC12F675
// 1Hz Time Base Osc.
// Timer1 Module
// 32.768 KHz
unsigned short tick;
void Init ();
void interrupt ()
{
if (PIR1.TMR1IF)
{
TMR1H = 0xE0;
PIR1.TMR1IF = 0;
tick = 1;
}
}
void main ()
{
tick = 0;
//Initialize Ports and Timer1 Module
Init ();
while (1)
{
if (tick)
{
tick = 0;
GPIO = (1 << 2);
}
if (TMR1H > 0xF0)
{
GPIO = 0;
}
}
}
void Init ()
Just added two braces at the end.In wonder how you managed to compile a broken source?
Hex file attached.
That is because the C code (it is not assembly code) that you posted is incomplete.this file not working
That is because the C code (it is not assembly code) that you posted is incomplete.
The void Init() function at the end of the code you posted is completely empty.
I suspect that you have missed a whole chunk of source code out from the end of your text file.
- - - Updated - - -
By the way....
You can download the C compiler for your code here: https://www.mikroe.com/mikroc/pic/
This is a limited demo version that you can use for free, but will work perfectly for this project.
Code C - [expand] 1 Init()
Code C - [expand] 1 InitTimer1()
Code attached. Seems to work, but no guarantees.
This is untested amateur code written (especially for you) in a hurry - plenty of scope for improvement.
He said no guarantees. You expect help, but you don't do anything yourself. Why don't you download the compiler he suggested and try to modify the code yourself?
Not to be mean or anything, but you're expecting someone else to do your whole work. Show some initiative...
pityu
Well don't you want to learn? Look at post #6 it has a link in it, download the compiler from there, and try to compile the code you gave us. From personal experience i can tell, that you will be getting lot more help on less generic questions.
pityu
Well don't you want to learn? Look at post #6 it has a link in it, download the compiler from there, and try to compile the code you gave us. From personal experience i can tell, that you will be getting lot more help on less generic questions.
pityu
Make: The target "C:\Documents and Settings\sethu\Desktop\Timer For Recom\New Folder\HMS.o" is out of date.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F88 "HMS.asm" /l"HMS.lst" /e"HMS.err"
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 6 : Symbol not previously defined (TRISB)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 8 : Symbol not previously defined (PORTB)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 10 : Symbol not previously defined (ANSEL)
Warning[202] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 12 : Argument out of range. Least significant bits used.
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 13 : Symbol not previously defined (OSCCON)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 17 : Symbol not previously defined (_d4_count)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 20 : Symbol not previously defined (_d4_count)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 21 : Symbol not previously defined (STATUS)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 24 : Symbol not previously defined (_d3_count)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 27 : Symbol not previously defined (_d3_count)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 28 : Symbol not previously defined (STATUS)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 31 : Symbol not previously defined (_d2_count)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 34 : Symbol not previously defined (_d2_count)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 35 : Symbol not previously defined (STATUS)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 38 : Symbol not previously defined (PORTB)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 41 : Symbol not previously defined (R11)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 43 : Symbol not previously defined (R12)
Warning[202] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 44 : Argument out of range. Least significant bits used.
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 45 : Symbol not previously defined (R13)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 47 : Symbol not previously defined (R13)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 49 : Symbol not previously defined (R12)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 51 : Symbol not previously defined (R11)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 56 : Symbol not previously defined (PORTB)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 59 : Symbol not previously defined (R11)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 61 : Symbol not previously defined (R12)
Warning[202] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 62 : Argument out of range. Least significant bits used.
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 63 : Symbol not previously defined (R13)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 65 : Symbol not previously defined (R13)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 67 : Symbol not previously defined (R12)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 69 : Symbol not previously defined (R11)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 74 : Symbol not previously defined (_d2_count)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 79 : Symbol not previously defined (_d2_state)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 81 : Symbol not previously defined (_d2_state)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 83 : Symbol not previously defined (PORTB)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 86 : Symbol not previously defined (PORTB)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 89 : Symbol not previously defined (_d3_count)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 94 : Symbol not previously defined (_d3_state)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 96 : Symbol not previously defined (_d3_state)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 98 : Symbol not previously defined (PORTB)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 101 : Symbol not previously defined (PORTB)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 104 : Symbol not previously defined (_d4_count)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 109 : Symbol not previously defined (_d4_state)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 111 : Symbol not previously defined (_d4_state)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 113 : Symbol not previously defined (PORTB)
Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 116 : Symbol not previously defined (PORTB)
Error[129] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 124 : Expected (END)
Error[173] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 124 : Source file path exceeds 62 characters (C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM)
Halting build on first failure as requested.
BUILD FAILED: Mon Aug 19 17:29:52 2013
Thank you Sir and I download the MPLAB 8.92 and I try to do......Thanks
Regards
- - - Updated - - -
Sir...
I Get error messages when I compile
This is the error messages
HTML:Make: The target "C:\Documents and Settings\sethu\Desktop\Timer For Recom\New Folder\HMS.o" is out of date. Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F88 "HMS.asm" /l"HMS.lst" /e"HMS.err" Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 6 : Symbol not previously defined (TRISB) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 8 : Symbol not previously defined (PORTB) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 10 : Symbol not previously defined (ANSEL) Warning[202] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 12 : Argument out of range. Least significant bits used. Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 13 : Symbol not previously defined (OSCCON) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 17 : Symbol not previously defined (_d4_count) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 20 : Symbol not previously defined (_d4_count) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 21 : Symbol not previously defined (STATUS) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 24 : Symbol not previously defined (_d3_count) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 27 : Symbol not previously defined (_d3_count) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 28 : Symbol not previously defined (STATUS) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 31 : Symbol not previously defined (_d2_count) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 34 : Symbol not previously defined (_d2_count) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 35 : Symbol not previously defined (STATUS) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 38 : Symbol not previously defined (PORTB) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 41 : Symbol not previously defined (R11) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 43 : Symbol not previously defined (R12) Warning[202] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 44 : Argument out of range. Least significant bits used. Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 45 : Symbol not previously defined (R13) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 47 : Symbol not previously defined (R13) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 49 : Symbol not previously defined (R12) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 51 : Symbol not previously defined (R11) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 56 : Symbol not previously defined (PORTB) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 59 : Symbol not previously defined (R11) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 61 : Symbol not previously defined (R12) Warning[202] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 62 : Argument out of range. Least significant bits used. Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 63 : Symbol not previously defined (R13) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 65 : Symbol not previously defined (R13) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 67 : Symbol not previously defined (R12) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 69 : Symbol not previously defined (R11) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 74 : Symbol not previously defined (_d2_count) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 79 : Symbol not previously defined (_d2_state) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 81 : Symbol not previously defined (_d2_state) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 83 : Symbol not previously defined (PORTB) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 86 : Symbol not previously defined (PORTB) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 89 : Symbol not previously defined (_d3_count) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 94 : Symbol not previously defined (_d3_state) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 96 : Symbol not previously defined (_d3_state) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 98 : Symbol not previously defined (PORTB) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 101 : Symbol not previously defined (PORTB) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 104 : Symbol not previously defined (_d4_count) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 109 : Symbol not previously defined (_d4_state) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 111 : Symbol not previously defined (_d4_state) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 113 : Symbol not previously defined (PORTB) Error[113] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 116 : Symbol not previously defined (PORTB) Error[129] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 124 : Expected (END) Error[173] C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM 124 : Source file path exceeds 62 characters (C:\DOCUMENTS AND SETTINGS\SETHU\DESKTOP\TIMER FOR RECOM\HMS.ASM) Halting build on first failure as requested. BUILD FAILED: Mon Aug 19 17:29:52 2013
Great! Now you'll need to sort these errors out. Start by selecting the correct device, the one you're working with: PIC16F88. You do that by selecting the PIC in the "Select device" window, under the "Configure" menu point.
In the left lower corner you'll see the device that is currently selected. Now you need a compiler, you can get it on microchip website:
https://www.microchip.com/pagehandler/en_us/devtools/mplabxc/
Your controller is 8-bits, so you need XC8 for this. Install it.
Then go to "Project" -> "Select language toolsuite" from the dropdown list select XC8. Press OK, and try to compile again. Let us know how it went.
pityu
I'm attaching a rar file to you just to get you started. I used hi-tech but aside of some minor changes, it should be compatible! try to run this, and to correct it. I am too, at this moment.
#include "htc.h"
__CONFIG(0x0770);
unsigned short tick;
void Init ();
volatile unsigned int counter = 0;
volatile unsigned char second_flag = 0;
unsigned char temp1, temp2, temp3 = 0;
void interrupt isr()
{
if((TMR0IF == 1) && (TMR0IE == 1))
{
if(counter < 10) counter++;
else
{
counter = 0;
second_flag = 1;
}
TMR0IF = 0;
TMR0 = 131; // preset for timer register
}
}
void main ()
{
Init();
while(1)
{
if(second_flag == 1)
{
second_flag = 0; // 1 second elapsed
PORTB &= 0x1F; // clear from RB4->7 after a second
RB4 = !RB4; // light up every second
temp1++;
if(temp1 == 60)
{
temp1 = 0;
temp2++;
RB5 = 1;
}
if(temp2 == 6)
{
temp2 = 0;
temp3++;
RB6 = 1;
}
if(temp3 == 2)
{
temp3 = 0;
RB7 = 1;
}
}
}
}
void Init ()
{
OSCCON = 0x72; // internal oscillator used, 8mhz
ANSEL = 0x00; // all digital I/O
TRISB = 0x0F; // RB4-7 outputs, rest inputs
PORTB = 0x00; // clear output latch
INTCON = 0xA0; // enable global and timer0 interrupts
OPTION_REG = 0xC3; // internal clock selected, 1:16 prescaler to timer1
TMR0 = 131; // preset for timer register
}
The basic idea is to get a flag to toggle every second. Increasing a variable every time this happens will allow you to trigger an event (RB5 goes high) when this variable reaches 60. The next second-interrupt you clear RB5. So you got an impulse when 60 seconds elapsed. You do the same with RB6 RB7, and that's it. RB4 needs to be toggled every second, so there you don't need a counter, it gets toggled every time the if loop is entered.
Code:#include "htc.h" __CONFIG(0x0770); unsigned short tick; void Init (); volatile unsigned int counter = 0; volatile unsigned char second_flag = 0; unsigned char temp1, temp2, temp3 = 0; void interrupt isr() { if((TMR0IF == 1) && (TMR0IE == 1)) { if(counter < 10) counter++; else { counter = 0; second_flag = 1; } TMR0IF = 0; TMR0 = 131; // preset for timer register } } void main () { Init(); while(1) { if(second_flag == 1) { second_flag = 0; // 1 second elapsed PORTB &= 0x1F; // clear from RB4->7 after a second RB4 = !RB4; // light up every second temp1++; if(temp1 == 60) { temp1 = 0; temp2++; RB5 = 1; } if(temp2 == 6) { temp2 = 0; temp3++; RB6 = 1; } if(temp3 == 2) { temp3 = 0; RB7 = 1; } } } } void Init () { OSCCON = 0x72; // internal oscillator used, 8mhz ANSEL = 0x00; // all digital I/O TRISB = 0x0F; // RB4-7 outputs, rest inputs PORTB = 0x00; // clear output latch INTCON = 0xA0; // enable global and timer0 interrupts OPTION_REG = 0xC3; // internal clock selected, 1:16 prescaler to timer1 TMR0 = 131; // preset for timer register }
this works, i just tested it. Here's a hex file too.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?