|
|
View previous topic :: View next topic |
Author |
Message |
vardhan Guest
|
access violation |
Posted: Fri Jan 01, 2010 6:38 am |
|
|
hi pals,
Access violation at address 02584d96 in module “PCH.dll”. Read of address
00000066
Contact ccs
Why am I getting this error at the fprintf statement? Please help me.
thx in advance. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 01, 2010 4:40 pm |
|
|
Post a short little (compilable) program that shows the problem.
Post your compiler version.
Post your version of Windows. |
|
|
vardhan Guest
|
accesss violation problem |
Posted: Fri Jan 01, 2010 11:23 pm |
|
|
Code: |
#include <18F4620.h>
#device adc=10
#fuses HS,WDT,NOPROTECT,BROWNOUT
#use delay(clock=20000000,RESTART_WDT)
#use i2c(MASTER,SDA=PIN_C4,SCL=PIN_C3,RESTART_WDT)
#USE RS232(baud=9600,xmit=pin_c6,rcv=pin_c7,bits=8,stop=1,parity=n,STREAM=PC,ERRORS,TIMEOUT=1000,restart_wdt)
#byte PORTA = 0xF80
#byte PORTB = 0xF81
#byte PORTC = 0xF82
#byte PORTD = 0xF83
#byte PORTE = 0xF84
int1 RC_timeout=false;
int8 waitfor;
#define second (77)
unsigned int16 rv=230,yv=120,bvt=260,pvt=450,l1=230,l2=228,l3=231,dvt=000,slr=245;
float fq=48.5,pf=0.99,l1l=25.9,l2l=12.6,l3l=5.0,dfq=0.0,dbv=12.6,dl=0.0,dbtl=6.3,df=80.0,ptv=48.5,rt=24.5,at=28.3,rh=50.0,ah=65.3,ac1l=20.5,ac2l=15.6,pbtl=63.5,slrl=52.6;
char in_buffer[200];
INT16 ALM=0,ALM1=0;
int date,month,year,hour,min,sec;
#include<math.h>
#include<stddef.h>
#include<string.h>
#include<stdlib.h>
#int_timer0
void timer0isr()
{
if (waitfor) --waitfor;
else RC_timeout=true;
}
void ftget_string(char* s, int max, int ticks){
int len;
char c;
waitfor=ticks;
RC_timeout=false;
set_timer0(0);
clear_interrupt(int_timer0);
enable_interrupts(INT_TIMER0);
--max;
len=0;
do {
while (!kbhit(PC)){
if (RC_timeout){
c=10;
break;
}
}
if (kbhit(PC)) c=fgetc(PC);
if ((c>=' ')&&(c<='~'))
if(len<=max) {
s[len++]=c;
}
}while(c!=10);
s[len]=0;
disable_interrupts(INT_TIMER0);
}
#INT_RDA
void serial_isr()
{
ftget_string(in_buffer, 100, second);
}
#SEPARATE
VOID init_io()
{
set_tris_a(0X11);
set_tris_b(0x00);
set_tris_c(0xA4);
set_tris_d(0x17);
set_tris_e(0x00);
}
void main(){
init_io();
delay_ms(10);
// rtc_init();
//lcd_init();
delay_ms(200);
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
enable_interrupts(INT_RDA);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256|RTCC_8_BIT);
enable_interrupts(GLOBAL);
SETUP_WDT(WDT_ON);
while(TRUE)
{
RESTART_WDT();
fprintf(PC,"123456,5689712358,%02d%02d%02d,%02d%02d%02d,%LX%LX,%03ld,%03ld,%03ld,%03ld,%03ld,%03ld,%03ld,%03ld,%03ld,%04.1f,%02.2f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,%04.1f,#\r\n",date,month,year,hour,min,sec,ALM1,ALM,rv,yv,bvt,pvt,l1,l2,l3,dvt,slr,fq,pf,l1l,l2l,l3l,dfq,dbv,dl,dbtl,df,ptv,rt,at,rh,ah,ac1l,ac2l,pbtl,slrl);
}
}
|
ccs v 4.093, I tried in v4.084, v4.083 also.
Windows XP Professional 2002 service pack 2.
I tried to print on lcd also even then same probs. |
|
|
vardhan Guest
|
accesss violation problem |
Posted: Fri Jan 01, 2010 11:26 pm |
|
|
Access violation at address 02584d96 in module “PCH.dll”.Read of address 0000005B
Internal ERROR: Contact ccs |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 01, 2010 11:36 pm |
|
|
The error is occuring on the fprintf line. You may have an error in it,
or the compiler may simply not like the fact that it's so long.
I would break that line up into 4 smaller fprintf statements. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sat Jan 02, 2010 12:41 am |
|
|
I agree - that's a pretty hefty fprintf.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
vardhan Guest
|
accesss violation |
Posted: Sat Jan 02, 2010 2:34 am |
|
|
hi pals,
there is no error in fprintf,i split it into 2 fprintf's its working,but i need to send the whole data with one fprintf only.its my requirement in the project. |
|
|
vardhan Guest
|
accesss violation problem |
Posted: Sat Jan 02, 2010 3:08 am |
|
|
hi PCM,
the fprintf or printf is taking only 30 values maximum,is it the error in compiler or the CCS as restricted it to 30 values.is there any other method to send all values at once or i have to check some other compiler. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sat Jan 02, 2010 3:17 am |
|
|
Quote: | i need to send the whole data with one fprintf only.its my requirement in the project. |
Your free to specify arbitrary requirements. But I'm rather sure that it doesn't bring an advantage in terms of
code size. The compiler is cutting the printf statement anyway.
Generally, an access violation must be considered as a compiler bug, you should report it to CCS. If the compiler
has a built-in limitation regarding format string length or printf argument count, a errors message can be expected.
P.S.:
Quote: | is there any other method to send all values at once | They are not sent "at once" in a single printf statement. The compiler is feeding the serial output stream sequentially. If you have special requirements regarding the output processing, you may need to print the string to a buffer first. By default, the compiler avoids buffering to save resources.
Last edited by FvM on Sat Jan 02, 2010 3:24 am; edited 1 time in total |
|
|
Ttelmah Guest
|
|
Posted: Sat Jan 02, 2010 3:24 am |
|
|
Er. There is no advantage to sending it in one lump, so why not split it?.
It is not as if splitting it makes it take more time or space.
The values are always sent 'one after the other', anyway. Makes no difference whether the data is in one printf, two or more....
The compiler has a limited amount of temporary storage space for it's own use. With the printf so long, it is almost certinaly running out in allocatiing this as it tries to parse the string.
In all honesty, if you want to send this much, you would be better off buffering the printing anyway. It is going to take over 80mSec to complete, sitting for most of the time waiting for the serial...
There are also a couple of format strings, that don't really make much sense:
%02.2f
for example. Read up on what the number in front of the DP 'means' in C, and understand why it is pointless in this case, or needs to be larger...
Consider also using your own separate 'sub', to perform all the identical outputs, so something like:
Code: |
#separate
void three_long(int16 val) {
fprintf(PC,"%03ld,",val);
}
//Then in your main,for the values using %03ld
three_long(rv);
three_long(yv);
//etc..
|
You may be surprised at the effect on the code size.....
Best Wishes |
|
|
vardhan Guest
|
accesss violation problem |
Posted: Sat Jan 02, 2010 3:51 am |
|
|
hi,
My requirement is to send the fixed length of data/packet at once with a separator (,) between each variable and cr,lf at the end,so i have used %03ld.....so even if there is no value for the varaible it sends 000 instead of only one 0 and used only one fprintf. |
|
|
Ttelmah Guest
|
|
Posted: Sat Jan 02, 2010 6:40 am |
|
|
Yes.
Look and and _think_ about what is being done.
What I show can be used for each of the different formats you use. But the point is it develops just _one_ section of code for each format. The standard behaviour is to develop a complete routine for each format, _even if it is identical to the one before_. Huge waste of space...
Best Wishes |
|
|
|
|
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
|