|
|
View previous topic :: View next topic |
Author |
Message |
kloppy
Joined: 28 Jul 2004 Posts: 32
|
|
Posted: Mon Aug 02, 2004 12:53 pm |
|
|
i tried all your suggestion but nothing works. hardware is ok....
i don't know what to do...
could you please compile the program for my pic (16F876) and post the hex file and the lst file?
also the thing with the errors doesn't help. it just prints something like:
received
Ÿ@ : no errors
Û ï: no errors
Û ï: no errors
: no errors |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Aug 02, 2004 1:07 pm |
|
|
Post the code that you are trying to test right now. |
|
|
kloppy
Joined: 28 Jul 2004 Posts: 32
|
|
Posted: Mon Aug 02, 2004 1:17 pm |
|
|
i would be very happy if this one works:
Code: | #include <16F876.h>
#use delay (clock=20000000)
#use RS232 (baud=19200, xmit=pin_c6, rcv=pin_c7,bits=8,parity=n,errors,stream=STDERR)
#use standard_io(c)
#fuses HS, NOWDT, NOPROTECT, PUT, NOBROWNOUT, NOLVP
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
char input=0;
#int_rda
void serial_isr()
{
input=getc();
}
main()
{
enable_interrupts(int_rda);
enable_interrupts(global);
while (1)
{
delay_ms(1000);
printf("%C ",input);
printf("received ");
}
} |
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Aug 02, 2004 1:51 pm |
|
|
Here is the hex file:
Code: |
:1000000000308A006D280000FF00030E8301A1006C
:100010000A08A0008A010408A2007708A300780853
:10002000A4007908A5007A08A6007B08A70083131E
:1000300083128C308400801E1F288C1A32282208DC
:1000400084002308F7002408F8002508F900260892
:10005000FA002708FB0020088A00210E8300FF0E0B
:100060007F0E09008A110A1251280A108A100A11FB
:1000700082077234653463346534693476346534A8
:100080006434203400348C1E43281808A8001A0851
:10009000F800A81C4D281812181600008A110A1220
:1000A000522843287808B0008C128A110A121F289F
:1000B00032308400000803196A280630F800F7017E
:1000C000F70B6028F80B5F287B30F700F70B6628EA
:1000D000800B5D288A110A12912884011F30830544
:1000E00083161F149F141F159F114030990026304E
:1000F0009800903083129800A801FF30A900AA014F
:10010000AB010130AC00AD01AE01AF01B00183160F
:100110008C16C03083128B040430B100FA30B20068
:100120005828B10B8E2830080C1E942899002030D6
:100130000C1E98289900B10131083520B10AF7004A
:1001400077080C1EA128990009303102031D9C2854
:040150008C28630094
:02400E00323F3F
:00000001FF
;PIC16F876
|
Here is the lst file:
Code: |
CCS PCM C Compiler, Version 3.206, 22485 02-Aug-04 15:53
Filename: test.LST
ROM used: 163 words (2%)
Largest free fragment is 2048
RAM used: 17 (10%) at main() level
18 (10%) worst case
Stack: 3 worst case (1 in main + 2 for interrupts)
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 06D
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 0A,W
0009: MOVWF 20
000A: CLRF 0A
000B: MOVF 04,W
000C: MOVWF 22
000D: MOVF 77,W
000E: MOVWF 23
000F: MOVF 78,W
0010: MOVWF 24
0011: MOVF 79,W
0012: MOVWF 25
0013: MOVF 7A,W
0014: MOVWF 26
0015: MOVF 7B,W
0016: MOVWF 27
0017: BCF 03.7
0018: BCF 03.5
0019: MOVLW 8C
001A: MOVWF 04
001B: BTFSS 00.5
001C: GOTO 01F
001D: BTFSC 0C.5
001E: GOTO 032
001F: MOVF 22,W
0020: MOVWF 04
0021: MOVF 23,W
0022: MOVWF 77
0023: MOVF 24,W
0024: MOVWF 78
0025: MOVF 25,W
0026: MOVWF 79
0027: MOVF 26,W
0028: MOVWF 7A
0029: MOVF 27,W
002A: MOVWF 7B
002B: MOVF 20,W
002C: MOVWF 0A
002D: SWAPF 21,W
002E: MOVWF 03
002F: SWAPF 7F,F
0030: SWAPF 7F,W
0031: RETFIE
0032: BCF 0A.3
0033: BCF 0A.4
0034: GOTO 051
.................... #include <16F876.h>
.................... //////// Standard Header file for the PIC16F876 device ////////////////
.................... #device PIC16F876
.................... #list
....................
.................... #use delay (clock=20000000)
*
0058: MOVLW 2C
0059: MOVWF 04
005A: MOVF 00,W
005B: BTFSC 03.2
005C: GOTO 06A
005D: MOVLW 06
005E: MOVWF 78
005F: CLRF 77
0060: DECFSZ 77,F
0061: GOTO 060
0062: DECFSZ 78,F
0063: GOTO 05F
0064: MOVLW 7B
0065: MOVWF 77
0066: DECFSZ 77,F
0067: GOTO 066
0068: DECFSZ 00,F
0069: GOTO 05D
006A: BCF 0A.3
006B: BCF 0A.4
006C: GOTO 08A (RETURN)
.................... #use RS232 (baud=19200, xmit=pin_c6, rcv=pin_c7,bits=8,parity=n,errors,stream=STDERR)
*
0043: BTFSS 0C.5
0044: GOTO 043
0045: MOVF 18,W
0046: MOVWF 28
0047: MOVF 1A,W
0048: MOVWF 78
0049: BTFSS 28.1
004A: GOTO 04D
004B: BCF 18.4
004C: BSF 18.4
004D: NOP
004E: BCF 0A.3
004F: BCF 0A.4
0050: GOTO 052 (RETURN)
*
007C: CLRF 28
.................... #use standard_io(c)
007D: MOVLW FF
007E: MOVWF 29
.................... #fuses HS, NOWDT, NOPROTECT, PUT, NOBROWNOUT, NOLVP
.................... //#include <errno.h>
.................... //#include <stdio.h>
.................... //#include <stdlib.h>
....................
.................... char input=0;
007F: CLRF 2A
....................
.................... #int_rda
.................... void serial_isr(void)
.................... {
.................... input=getc();
*
0051: GOTO 043
0052: MOVF 78,W
0053: MOVWF 2A
.................... }
....................
....................
0054: BCF 0C.5
0055: BCF 0A.3
0056: BCF 0A.4
0057: GOTO 01F
.................... void main(void)
.................... {
*
006D: CLRF 04
006E: MOVLW 1F
006F: ANDWF 03,F
0070: BSF 03.5
0071: BSF 1F.0
0072: BSF 1F.1
0073: BSF 1F.2
0074: BCF 1F.3
0075: MOVLW 40
0076: MOVWF 19
0077: MOVLW 26
0078: MOVWF 18
0079: MOVLW 90
007A: BCF 03.5
007B: MOVWF 18
.................... enable_interrupts(int_rda);
*
0080: BSF 03.5
0081: BSF 0C.5
.................... enable_interrupts(global);
0082: MOVLW C0
0083: BCF 03.5
0084: IORWF 0B,F
.................... while (1)
.................... {
.................... delay_ms(1000);
0085: MOVLW 04
0086: MOVWF 2B
0087: MOVLW FA
0088: MOVWF 2C
0089: GOTO 058
008A: DECFSZ 2B,F
008B: GOTO 087
.................... printf("%C ",input);
008C: MOVF 2A,W
008D: BTFSS 0C.4
008E: GOTO 08D
008F: MOVWF 19
0090: MOVLW 20
0091: BTFSS 0C.4
0092: GOTO 091
0093: MOVWF 19
.................... printf("received ");
0094: CLRF 2B
0095: MOVF 2B,W
0096: CALL 035
0097: INCF 2B,F
0098: MOVWF 77
0099: MOVF 77,W
009A: BTFSS 0C.4
009B: GOTO 09A
009C: MOVWF 19
009D: MOVLW 09
009E: SUBWF 2B,W
009F: BTFSS 03.2
00A0: GOTO 095
.................... }
00A1: GOTO 085
.................... }
....................
00A2: SLEEP
Configuration Fuses:
Word 1: 3F32 HS NOWDT PUT NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG
|
Note that I commented out some includes to shorten the lst file (only for the lst file, the hex is exactly how you posted the code).
I changed the device to an 18F452 (because that is what I am currently working with) and the programmed worked as expected.
Last edited by Mark on Mon Aug 02, 2004 2:06 pm; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Aug 02, 2004 2:03 pm |
|
|
Quote: | also the thing with the errors doesn't help. it just prints something like:
received
Ÿ@ : no errors
Û ï: no errors
Û ï: no errors
: no errors |
I compiled your program with PCM vs. 3.110 and I examined the .LST
file. (I commented out the #nolist statement in 16F876.H, so I could
see all the code).
I found the string "no errors" in the string.h file, in the strerror()
function. But there's no code compiled for it. It doesn't appear
in the program.
Somehow, in your program, with your compiler, strerror() is being
compiled. I don't yet understand what's going on. I copied your
code verbatim into MPLAB. There is some crucial difference between
your compiler/editor environment and mine. Something is causing
strerror() to be put into your program. Or, the program you posted
is not the same as the one you're testing. |
|
|
kloppy
Joined: 28 Jul 2004 Posts: 32
|
|
Posted: Mon Aug 02, 2004 3:02 pm |
|
|
PCM programmer wrote: | Quote: | also the thing with the errors doesn't help. it just prints something like:
received
Ÿ@ : no errors
Û ï: no errors
Û ï: no errors
: no errors |
I compiled your program with PCM vs. 3.110 and I examined the .LST
file. (I commented out the #nolist statement in 16F876.H, so I could
see all the code).
I found the string "no errors" in the string.h file, in the strerror()
function. But there's no code compiled for it. It doesn't appear
in the program.
Somehow, in your program, with your compiler, strerror() is being
compiled. I don't yet understand what's going on. I copied your
code verbatim into MPLAB. There is some crucial difference between
your compiler/editor environment and mine. Something is causing
strerror() to be put into your program. Or, the program you posted
is not the same as the one you're testing. |
no, sorry, i didn't post the program with the error thing. i thought that couldn't solve my problem
BUT I downloaded the hexfile from Mark and it works!!!!! output is: u received u received u received u received
so what am i doing wrong?? did i forget some settings? this is my lst file: Code: | CCS PCM C Compiler, Version 3.110, 15948
Filename: primitiver_test.LST
ROM used: 161 (2%)
Largest free fragment is 2048
RAM used: 17 (10%) at main() level
18 (10%) worst case
Stack: 3 worst case (1 in main + 2 for interrupts)
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 06D
0003: NOP
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 0A,W
0009: MOVWF 20
000A: CLRF 0A
000B: MOVF 04,W
000C: MOVWF 22
000D: MOVF 77,W
000E: MOVWF 23
000F: MOVF 78,W
0010: MOVWF 24
0011: MOVF 79,W
0012: MOVWF 25
0013: MOVF 7A,W
0014: MOVWF 26
0015: MOVF 7B,W
0016: MOVWF 27
0017: BCF 03.7
0018: BCF 03.5
0019: MOVLW 8C
001A: MOVWF 04
001B: BTFSS 00.5
001C: GOTO 01F
001D: BTFSC 0C.5
001E: GOTO 032
001F: MOVF 22,W
0020: MOVWF 04
0021: MOVF 23,W
0022: MOVWF 77
0023: MOVF 24,W
0024: MOVWF 78
0025: MOVF 25,W
0026: MOVWF 79
0027: MOVF 26,W
0028: MOVWF 7A
0029: MOVF 27,W
002A: MOVWF 7B
002B: MOVF 20,W
002C: MOVWF 0A
002D: SWAPF 21,W
002E: MOVWF 03
002F: SWAPF 7F,F
0030: SWAPF 7F,W
0031: RETFIE
0032: BCF 0A.3
0033: BCF 0A.4
0034: GOTO 051
....................
.................... #include <16F876.h>
.................... //////// Standard Header file for the PIC16F876 device ////////////////
.................... #device PIC16F876
.................... #list
....................
.................... #use delay (clock=20000000)
*
0058: MOVLW 2C
0059: MOVWF 04
005A: MOVF 00,W
005B: BTFSC 03.2
005C: GOTO 06A
005D: MOVLW 06
005E: MOVWF 78
005F: CLRF 77
0060: DECFSZ 77,F
0061: GOTO 060
0062: DECFSZ 78,F
0063: GOTO 05F
0064: MOVLW 7B
0065: MOVWF 77
0066: DECFSZ 77,F
0067: GOTO 066
0068: DECFSZ 00,F
0069: GOTO 05D
006A: BCF 0A.3
006B: BCF 0A.4
006C: GOTO 08A (RETURN)
.................... #use RS232 (baud=19200, xmit=pin_c6, rcv=pin_c7,bits=8,parity=n,errors,stream=STDERR)
*
0043: BTFSS 0C.5
0044: GOTO 043
0045: MOVF 18,W
0046: MOVWF 28
0047: MOVF 1A,W
0048: MOVWF 78
0049: BTFSS 28.1
004A: GOTO 04D
004B: BCF 18.4
004C: BSF 18.4
004D: NOP
004E: BCF 0A.3
004F: BCF 0A.4
0050: GOTO 052 (RETURN)
.................... #use standard_io(c)
.................... #fuses HS, NOWDT, NOPROTECT, PUT, NOBROWNOUT, NOLVP
....................
.................... char input=0;
....................
.................... #int_rda
.................... void serial_isr()
.................... {
.................... input=getc();
0051: GOTO 043
0052: MOVF 78,W
0053: MOVWF 2A
0054: BCF 0C.5
0055: BCF 0A.3
0056: BCF 0A.4
0057: GOTO 01F
.................... }
....................
.................... main()
.................... {
*
006D: CLRF 04
006E: MOVLW 1F
006F: ANDWF 03,F
0070: MOVLW 07
0071: BSF 03.5
0072: MOVWF 1F
0073: BCF 03.5
0074: CLRF 28
0075: MOVLW 40
0076: BSF 03.5
0077: MOVWF 19
0078: MOVLW 26
0079: MOVWF 18
007A: MOVLW 90
007B: BCF 03.5
007C: MOVWF 18
007D: MOVLW FF
007E: MOVWF 29
007F: CLRF 2A
.................... enable_interrupts(int_rda);
0080: BSF 03.5
0081: BSF 0C.5
.................... enable_interrupts(global);
0082: MOVLW C0
0083: BCF 03.5
0084: IORWF 0B,F
.................... while (1)
.................... {
.................... delay_ms(1000);
0085: MOVLW 04
0086: MOVWF 2B
0087: MOVLW FA
0088: MOVWF 2C
0089: GOTO 058
008A: DECFSZ 2B,F
008B: GOTO 087
.................... printf("%C ",input);
008C: MOVF 2A,W
008D: BTFSS 0C.4
008E: GOTO 08D
008F: MOVWF 19
0090: MOVLW 20
0091: BTFSS 0C.4
0092: GOTO 091
0093: MOVWF 19
.................... printf("received ");
*
0035: BCF 0A.0
0036: BCF 0A.1
0037: BCF 0A.2
0038: ADDWF 02,F
0039: RETLW 72
003A: RETLW 65
003B: RETLW 63
003C: RETLW 65
003D: RETLW 69
003E: RETLW 76
003F: RETLW 65
0040: RETLW 64
0041: RETLW 20
0042: RETLW 00
*
0094: CLRF 2B
0095: MOVF 2B,W
0096: CALL 035
0097: INCF 2B,F
0098: BTFSS 0C.4
0099: GOTO 098
009A: MOVWF 19
009B: MOVLW 09
009C: SUBWF 2B,W
009D: BTFSS 03.2
009E: GOTO 095
.................... }
009F: GOTO 085
.................... }
....................
00A0: SLEEP |
and this is the program: Code: | #include <16F876.h>
#use delay (clock=20000000)
#use RS232 (baud=19200, xmit=pin_c6, rcv=pin_c7,bits=8,parity=n,errors,stream=STDERR)
#use standard_io(c)
#fuses HS, NOWDT, NOPROTECT, PUT, NOBROWNOUT, NOLVP
char input=0;
#int_rda
void serial_isr()
{
input=getc();
}
main()
{
enable_interrupts(int_rda);
enable_interrupts(global);
while (1)
{
delay_ms(1000);
printf("%C ",input);
printf("received ");
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Aug 02, 2004 3:52 pm |
|
|
Mark used vs. 3.206 to compile the file. Try this one.
I compiled it with vs. 3.110.
Code: | :1000000000308A006D280000FF00030E8301A1006C
:100010000A08A0008A010408A2007708A300780853
:10002000A4007908A5007A08A6007B08A70083131E
:1000300083128C308400801E1F288C1A32282208DC
:1000400084002308F7002408F8002508F900260892
:10005000FA002708FB0020088A00210E8300FF0E0B
:100060007F0E09008A110A1251280A108A100A11FB
:1000700082077234653463346534693476346534A8
:100080006434203400348C1E43281808A8001A0851
:10009000F800A81C4D281812181600008A110A1220
:1000A000522843287808AA008C128A110A121F28A5
:1000B0002C308400000803196A280630F800F70184
:1000C000F70B6028F80B5F287B30F700F70B6628EA
:1000D000800B5D288A110A128A2884011F3083054B
:1000E000073083169F008312A801403083169900C1
:1000F00026309800903083129800FF30A900AA01A2
:1001000083168C16C03083128B040430AB00FA3097
:10011000AC005828AB0B87282A080C1E8D289900A4
:1001200020300C1E91289900AB012B083520AB0A1A
:100130000C1E9828990009302B02031D952885284C
:0201400063005A
:02400E00323F3F
:00000001FF
;PIC16F876 |
|
|
|
kloppy
Joined: 28 Jul 2004 Posts: 32
|
|
Posted: Tue Aug 03, 2004 10:50 am |
|
|
ok your hex file also works fine...
so maybe mplab isn't working properly? i use version 6.50 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 03, 2004 11:36 am |
|
|
Compile the source code that you posted on August 2 (just above)
and then compare the HEX file to the one that I posted. You can do
this by opening a DOS window and using the fc.exe file comparison utility.
Example:
fc /b "\program files\picc\projects\test\test.hex" c:\temp\test.hex
(Or, post your hex file, and I'll compare them). |
|
|
kloppy
Joined: 28 Jul 2004 Posts: 32
|
|
Posted: Tue Aug 03, 2004 1:50 pm |
|
|
fc says that your hex file is longer than mine... if you want to test it yourself here is my hex file: Code: | :1000000000308A006B280000FF00030E8301A1006E
:100010000A08A0008A010408A2007708A300780853
:10002000A4007908A5007A08A6007B08A70083131E
:1000300083128C308400801E1F288C1A32282208DC
:1000400084002308F7002408F8002508F900260892
:10005000FA002708FB0020088A00210E8300FF0E0B
:100060007F0E09008A110A1251280A108A100A11FB
:1000700082077234653463346534693476346534A8
:100080006434203400348C1E43281808A8001A0851
:10009000F800A81C4D281812181600008A110A1220
:1000A000522843287808AA008C128A110A121F28A5
:1000B0002C308400000803196A280230F800F70188
:1000C000F70B6028F80B5F289730F700F70B6628CE
:1000D000800B5D28003484011F30830507308316B0
:1000E0009F008312A80119308316990026309800CA
:1000F000903083129800FF30A900AA0183168C1655
:10010000C03083128B040230AB00FA30AC005820B0
:10011000AB0B85280230AB00FA30AC005820AB0B9B
:100120008C282A080C1E9228990020300C1E962834
:100130009900AB012B083520AB0A0C1E9D289900B5
:0C01400009302B02031D9A28832863005D
:02400E00323F3F
:00000001FF
;PIC16F876
|
|
|
|
kloppy
Joined: 28 Jul 2004 Posts: 32
|
|
Posted: Tue Aug 03, 2004 1:51 pm |
|
|
NO SORRY IT WAS THE WRONG PROGRAM.. |
|
|
kloppy
Joined: 28 Jul 2004 Posts: 32
|
|
Posted: Tue Aug 03, 2004 2:03 pm |
|
|
this is the hex file from the code from above. i can't get any useful informations from fc Code: | :1000000000308A006D280000FF00030E8301A1006C
:100010000A08A0008A010408A2007708A300780853
:10002000A4007908A5007A08A6007B08A70083131E
:1000300083128C308400801E1F288C1A32282208DC
:1000400084002308F7002408F8002508F900260892
:10005000FA002708FB0020088A00210E8300FF0E0B
:100060007F0E09008A110A1251280A108A100A11FB
:1000700082077234653463346534693476346534A8
:100080006434203400348C1E43281808A8001A0851
:10009000F800A81C4D281812181600008A110A1220
:1000A000522843287808AA008C128A110A121F28A5
:1000B0002C308400000803196A280630F800F70184
:1000C000F70B6028F80B5F287B30F700F70B6628EA
:1000D000800B5D288A110A128A2884011F3083054B
:1000E000073083169F008312A801403083169900C1
:1000F00026309800903083129800FF30A900AA01A2
:1001000083168C16C03083128B040430AB00FA3097
:10011000AC005828AB0B87282A080C1E8D289900A4
:1001200020300C1E91289900AB012B083520AB0A1A
:100130000C1E9828990009302B02031D952885284C
:0201400063005A
:02400E00323F3F
:00000001FF
;PIC16F876
|
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Aug 03, 2004 2:14 pm |
|
|
The above file is exactly the same and the one PCM programmer supplied you. |
|
|
kloppy
Joined: 28 Jul 2004 Posts: 32
|
|
Posted: Tue Aug 03, 2004 2:29 pm |
|
|
so mplab MUST be the bug?!? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 03, 2004 2:38 pm |
|
|
OK, if your hex file (the correct one) is the same as my HEX file,
and my HEX file works on your system, then what does this mean ?
Possibilities:
1. The file that you are programming into your PIC may not be the
file that is created when you compile. ie., You may be using some
old HEX file from a different directory than your project directory.
So even though you make all sorts of changes to your source
and try them, nothing ever seems to work because you're not
programming the latest file into the PIC. You need to check
if this is happening.
2. When you import a HEX file into MPLAB and then program it into
the PIC, it's a different process than compiling a file and programming
it. It's possible that the fuse settings ("config bits") are not being
properly updated by MPLAB before it programs the PIC. I have seen
this happen on older versions of MPLAB (4.xx perphaps) but I've
not seen it recently. Right before you program the PIC, you need
to look at the window that has the Config Bit settings and verify
that they match the ones in your program.
3. Also, I don't know what programmer you're using. Can you tell us ?
There are settings within the programmer setup window, that allow
you to reduce the address range which is programmed. If you
reduced it too much, then not all of your program would be burned
into the PIC. Are you doing anything like this ? |
|
|
|
|
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
|