View previous topic :: View next topic |
Author |
Message |
TIMT
Joined: 02 Sep 2005 Posts: 49 Location: Nottingham, UK
|
stack overflow in MPLAB run mode |
Posted: Mon Oct 03, 2005 5:26 am |
|
|
Hi,
I'm using MPLAB V7.00 and the latest version of CCS. When I compile and then RUN my project in MPLAB I keep getting UART-W0006 warnings and stack overflow problems. I can't seem to put my finger on what is wrong. I've attached the code, it's fairly simple. If I don't setup the UART the problem goes away, it also occurs when using printf to an LCD. Any ideas?
Code: |
#include <16F877A.h>
#fuses NOWDT,XT, PUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=4000000)
#use rs232(baud=2400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
int M25P40_id(); // Prototype for reading the ID of M25P40.
#define HOLD_bar PIN_C0 // Used for the M25P40 flash routines
#define WR_bar PIN_C1 // Used for the M25P40 flash routines
#define SYNC_bar PIN_B6 // Used for the M25P40 flash routines
void main()
{
int dataout;
while (1)
{
dataout = M25P40_id(); // Read the M25P40 ID into data
}
}
int M25P40_id() // Function for reading the ID of a M25P40 flash device.
{
int data;
setup_spi(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_16 | SPI_XMIT_L_TO_H);
output_high(SYNC_bar); // Sync_bar line high
output_low(SYNC_bar); // Sync_bar line low
spi_write(0b10101011); // Read ID.
spi_write(0x00); // Dummy byte
spi_write(0x00); // Dummy byte
spi_write(0x00); // Dummy byte
data = spi_read(0x00); // Read data
output_high(SYNC_bar); // Sync_bar line high
setup_spi(SPI_SS_DISABLED); // Disable the SPI bus
return data;
}
WARNING MESSAGES GENERATED :-
UART-W0006: Receive file has no data or failed to attach
when UART receive mode Enabled.
CORE-E0001: Stack over flow error occurred from instruction at 0x000168 |
_________________ Tim |
|
|
Ttelmah Guest
|
|
Posted: Mon Oct 03, 2005 7:06 am |
|
|
Have you possibly got a stimulus file setup in the simulator?. I have seen similar behaviour, when I had the simulator set to receive characters, and had not included any code to handle them.
Best Wishes |
|
|
TIMT
Joined: 02 Sep 2005 Posts: 49 Location: Nottingham, UK
|
|
Posted: Mon Oct 03, 2005 8:02 am |
|
|
Hello there, No I haven't a stimulus file set up, that may be the problem. I think I may need to have a look at creating one. Thanks
Tim. _________________ Tim |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
TIMT
Joined: 02 Sep 2005 Posts: 49 Location: Nottingham, UK
|
|
Posted: Tue Oct 04, 2005 2:29 am |
|
|
Thanks for your reply, I'll update MPLAB when I get chance. _________________ Tim |
|
|
TIMT
Joined: 02 Sep 2005 Posts: 49 Location: Nottingham, UK
|
|
Posted: Tue Oct 04, 2005 3:20 am |
|
|
Thanks for your help. I updated to V7.20 and all my warning messages to do with stack overflow and the UART seem to have vanished! touch wood.
Regards Tim. _________________ Tim |
|
|
TIMT
Joined: 02 Sep 2005 Posts: 49 Location: Nottingham, UK
|
|
Posted: Thu Oct 06, 2005 6:44 am |
|
|
Hi there,
Having updated to MPLAB V7.20 then V7.21 which got rid of the UART problem, I've found that when I try to assemble previous assembly code projects I get a CONFIG directive error, so unfortunately I've had to go back to V7.00 until Microchip get back to me with an answer. I'm in the process of converting my old .asm projects to .c ones with ccs but until then I'll have to stick with v7.00 unless anyone here knows the answer? _________________ Tim |
|
|
TIMT
Joined: 02 Sep 2005 Posts: 49 Location: Nottingham, UK
|
|
Posted: Thu Oct 06, 2005 8:57 am |
|
|
Just for info, the problem was with the NEW directive in V7.20 called CONFIG - was __CONFIG. I had a label called CONFIG in my .asm code which it now thinks is a directive and through up an error. I renamed the label CONFIG to MYCONFIG and ok now. I don'f know if CCS would ever generate a label called CONFIG I hope not. Must be a lot of code out there with CONFIG as a label. _________________ Tim |
|
|
|