j'aurais pu poster mon probleme sur MikroC, mais c'est peut etre plus instructif ici
le malheur des uns faisant le bonheur des autres
Je travaille sur le module WIFI-click 3 et veut pouvoir definir une page web > 256 octets.
il y a la place pour ...
A un moment donné on envoi le contenu de la page web au module WIFI,
mais deja, rien qu'au niveau de l'UART je trouve une limitation ..
impossible d'envoyer 286 cars en 1 seule fois via la fonction mikroC
UART1_Write_Text..
debordement de variable quelque par => affolement du programme
alors que si je scinde en 2 l'envoi .. OK no problemo avec 2 demi pages.(taille 2x142)
OU SERAIT-DONC cette limite ?
je n'ai pas décomposé le listing ASM correspondant pour y chercher une reponse... si j'ecris en C, c'est pas pour me casser la tete en ASM.
et pourtant comme dirait Maî .. ASM quand tu nous tiens..
on te tiens aussi.voici le bout de code concerné :
Code : Tout sélectionner
#define Version "160506"
#define Projet "WiFI3_Serveur_18F87J50_UART1_2_LCD_I2C2_Mai_2016.mcppi"
//#define Source "WiFI3_Serveur_UART2_UART1_LCD_I2C_HID_mikrobus1"
#define Source "test_envoi_page_HTML_"
// Tools -> Options -> cocher Case sensitive
#define Nom_Reseau_Wifi "ON_Air"
#define Mot_de_Passe ""
#define With_UART
//ac:Interliaisons_PIC_Wifi3
//ac:Pinout_18F87J50
//ac:datasheet
/* **************************************
PIC18FxxJxx Specifics
Shared Address SFRs
mikroC PRO for PIC does not provide auto setting of bit for acessing alternate register.
This is new feature added to PIC18fxxJxx family and will be supported in future.
In several locations in the SFR bank, a single address is used to access two
different hardware registers. In these cases, a “legacy” register of the standard PIC18
SFR set (such as OSCCON, T1CON, etc.) shares its address with an alternate register.
These alternate registers are associated with enhanced configuration options for peripherals,
or with new device features not included in the standard PIC18 SFR map.
A complete list of shared register addresses and the registers associated with them
is provided in datasheet.
**************************************
*/
// .. PB Timer0"
// passe à FOSC 8MHz interne au lieu de 48Mhz
// problemes liés à la taille RAM de buffer1 et buffer2 de 300
// si taille limitée à 256, l'interrupt timer0 repond bien
// par contre il faut veiller à ce que buffer2 ne deborde pas
// surtout avec la commande de decouverte reseau..
//
// int Send_Cde_Test_response(const char *cde,const char * answ)
// pour liste des reseaux dispo
// Activation IT RXW UART1 pour cde directe modukle WIFI3
// modif UART2 à 19200 bauds
//carte clicker2 18F87J50 cramée en envoyant +12V sur VSYS bornier (5V)!
// mais encore operationelle si alimentée en 3,3V (hormis la partie 5V et chargeur de batterie)
/*
Test configuration:
MCU: PIC18F87J50
Dev.Board: PICClicker2
Oscillator: HS-PLL 32.0000 MHz, 8.0000 MHz Crystal
ext. modules: wifi3 click board -
UART2 + terminal VBRAY
SW: mikroC PRO 6.50 for PIC
NOTES:
- Place WiFi3 click board in the mikroBUS socket #1
- Put power supply jumper (J5) on the EasyPIC7 board in 3.3V position.
- Configure SSId, password and port to match your network settings.
- Use UDP terminal tool to connect to the WiFi module and send data to it.
*/
//MicroBus Socket #1
//--- left ---------
//RA0 AN STAT
//RD2 RST POWERKEY
//---- right -------
//RG3 PWM RI PWD
//RB3 INT CTS GIO15
//RG2 RX TXD
//RG1 TX RXD
//
// nota: PIC 18F87J50 Clicker2
// Pins reservés , non utilisables
// RJ5 Stat
// partie Alim carte
// RF6 Vsense
// RE2 input Test presence alim USB
// RE5 Sensel
// RE6 Fault
//
// RD4 affecté à LD1 LED tirée au Gnd 1= Allumée
// RE4 affecté à LD2 LED tirée au Gnd 1= Allumée
// RD7 affecté à T2 BP1 tiré au +Vcc 1= BP Ouvert
// RH3 affecté à T3 BP2 tiré au +Vcc 1= BP Ouvert
// LCD éx16 car sur I2C2
// RD6 SCL I2C2 --> LCD2119 pin 3 fil vert
// RD5 SDA I2C2 --> LCD2119 pin4 fil jaune
// +3,3V ---------- LCD2119 pin2 fil rouge
// Gnd ---------- LCD2119 pin1 fil Noir
//#include "WiFI3_click_UART2_.h"
#define Lo(param) ((char *)¶m)[0]
#define Hi(param) ((char *)¶m)[1]
//-- commandes terminal VT220
#define CLS 12 // effacement de page sur Terminal VBRAY
#define CR 13
#define VT 10
#define LF 10
#define TAB 9
#define Bell 7
unsigned char WebPage[768];
unsigned const char WebHead[]=
"<html>\
<head>\
<meta http-equiv=\"Content-Type\"\
content=\"text/html; charset=iso-8859-1\">\
<meta http-equiv=\"refresh\" content=\"10\">\
<title>WIFI3-Click</title>\
</head>\
<body>\
<h2><br>";
unsigned char WebVar0[]="Temper. Ext :<br> 10.54 °C<br>";
unsigned char WebVar1[]="Temper. Amb :<br> 17.63 °C<br>";
unsigned char WebVar2[]="BP1 = x<br>";
unsigned char WebVar3[]="BP2 = x<br>";
unsigned char WebVar4[]="Idx = xxx<br>";
unsigned const char WebTail[]= "</h2></body></html>" ;
#define Byte unsigned Char
#define Word unsigned int
#define MAXLEN1 255
unsigned char buffer1[MAXLEN1];
static char msg[128];
static char TEXTE[256];
char CRam1[80];
char *txt;
unsigned char *p;
unsigned char Web_Status='0';
Word PageLen;
unsigned int Index1=0;
unsigned int i1=0;
unsigned int UART1_DataReady=0;
unsigned char c1=0;
unsigned char cx;
unsigned int i,j,k;
unsigned int Flag_Timer0;
unsigned int Cpt0;
int Vbray;
int Max_Timer0=2;
unsigned int Flag_Timer1;
unsigned int Cpt1;
unsigned int EAx,EA0,EA1,EA2;
float Degres1,Degres2;
char received_data[16], ip_address[16];
unsigned char tmp;
unsigned int Step;
unsigned char IPD=0;
// module connections click#1
sbit CH_PD at LATA0_bit; // resert pin
sbit GPIO15 at LATD2_bit;
sbit CH_PD_Direction at LATA0_bit;
sbit GPIO15_Direction at LATD2_bit;
// LEDs on PIC18F87J50 Clicker2
sbit LD1 at LATD4_bit;
sbit LD2 at LATE4_bit;
sbit LD1_Direction at TRISD4_bit;
sbit LD2_Direction at TRISE4_bit;
// BPs on PIC18F87J50 Clicker2
sbit BP1 at RD7_bit;
sbit BP2 at RH3_bit;
sbit BP1_Direction at TRISD7_bit;
sbit BP2_Direction at TRISH3_bit;
void strConstRamCpy(char *dest, const char *source);
void Init_ADC(void);
void CRLF1(void) ;
void UART1_Write_CText(const char *txt);
void RAZ_UART1(void);
void Float2Ascii (float x, unsigned char *str,char precision);
// interrupt handler
void Interrupts() iv 0x0008 ics ICS_AUTO
{
//UART1
if((RC1IF_bit==1) && (RC1IE_bit==1))
{
c1 = RCREG1;
//TXREG1='*';
if(OERR1_bit)
{
CREN1_bit = 0;
CREN1_bit = 1;
OERR2_bit = 0;
}
if(FERR1_bit)
{
c1 = RCREG1;
}
if ((c1==13) || (i1>MAXLEN1)) //|| (c1==10))
{
UART1_DataReady=1;
buffer1[i1]=0;
Index1=i1;
i1=0;
c1=0;
}
else
{
if (c1>0)
{
buffer1[i1]=c1;
Index1=i1;
i1++;
}
}
}
}
void Float2Ascii (float x, unsigned char *str,char precision)
{
/* converts a floating point number to an ascii string */
/* x is stored into str, which should be at least 30 chars long */
int ie, i, k, ndig;
double y;
ndig = ( precision<=0) ? 7 : (precision > 22 ? 23 : precision+1);
ie = 0;
/* if x negative, write minus and reverse */
if ( x < 0)
{
*str++ = '-';
x = -x;
}
/* put x in range 1 <= x < 10 */
if (x > 0.0) while (x < 1.0)
{
x *= 10.0; // a la place de =*
ie--;
}
while (x >= 10.0)
{
x = x/10.0;
ie++;
}
// in f format, number of digits is related to size
ndig += ie; // a la place de =+
//round. x is between 1 and 10 and ndig will be printed to
// right of decimal point so rounding is ...
for (y = i = 1; i < ndig; i++)
y = y/10.;
x += y/2.;
if (x >= 10.0) {x = 1.0; ie++;}
if (ie<0)
{
*str++ = '0'; *str++ = '.';
if (ndig < 0) ie = ie-ndig;
for (i = -1; i > ie; i--) *str++ = '0';
}
for (i=0; i < ndig; i++)
{
k = x;
*str++ = k + '0';
if (i == ie ) *str++ = '.';
x -= (y=k);
x *= 10.0;
}
*str = '\0';
}
// --- Copie le texte depuis ROM vers RAM
void strConstRamCpy(char *dest, const char *source)
{
while(*source) *dest++ = *source++ ;
*dest = 0 ; // terminateur
}
void Init_ADC()
{
//config lecture ADC 10 bits
ADCON0.VCFG1=0; // - AVss=Gnd;
ADCON0.VCFG0=0; // +Avdd;
ADCON0.CHS3=0; // channel1
ADCON0.CHS2=0;
ADCON0.CHS1=0;
ADCON0.CHS0=1;
ADCON0.ADON=1; // ADC enabled
ADCON1.ADFM=1; // right justified
ADCON1.ADCAL=0;
ADCON1.ACQT2=1;
ADCON1.ACQT1=1;
ADCON1.ACQT0=0; // 110=> 16 TAD
ADCON1.ADCS1=1;
ADCON1.ADCS2=1;
ADCON1.ADCS0=0; // 110 => Fosc/64
}
void UART1_Write_CText(const char *txt1)
{
while (*txt1)
UART1_Write(*txt1++);
}
void CRLF1()
{
UART1_Write(CR);
UART1_Write(LF);
}
void RAZ_UART1()
{ RC1IE_bit=0 ;
for (Index1=0;Index1<MAXLEN1;Index1++) buffer1[Index1]=0;
Index1=0;
i1=0;
UART1_DataReady=0;
c1=0;
RC1IE_bit=1 ;
}
void Hardware_Init(void)
{
TRISG=0xFF;
TRISA=0xFF;
TRISB=0xFF ;
TRISC=0xFF;
TRISD=0xFD;
TRISE=0xFF; // all input
TRISH=0xFF; // all input
//ADSHR_bit = 1; // plante si lecture ADC
//REGISTER 21-3: ANCON0: A/D PORT CONFIGURATION REGISTER 2
ANCON0=0xFF ; // 0= analog 1= digital
ANCON0.F4=1; // PCFG4_bit=1; // RA4 digital
ANCON0.F3=1; // PCFG3_bit=1; // RA3 digital
ANCON0.F2=0; // PCFG2_bit=0; // RA2 Analog inp
ANCON0.F1=0; // PCFG1_bit=0; // RA1 Analog inp
ANCON0.F0=1; // PCFG0_bit=1; // RA0 digital
// REGISTER 21-4: ANCON1: A/D PORT CONFIGURATION REGISTER 1
ANCON1=0xFF; // No analog on AN15--AN10
// 2 BP poussoir clicker2
BP1_Direction = 1; // Set direction for buttons
BP2_Direction = 1; // RH3
// 2 Leds sur cliker2
LD1_Direction = 0; // Set direction for LEDs
LD2_Direction = 0;
LD1 = 0; // turn off LEDs
LD2 = 0;
//
CH_PD_Direction=0;
GPIO15_Direction=0;
}
void main()
{
// internal FOSC=8Mhz
OSCTUNE=0;
OSCTUNE.PLLEN = 1;
OSCCON.IDLEN=0;
OSCCON.IRCF2=1; // 8Mhz
OSCCON.IRCF1=1;
OSCCON.IRCF0=1;
//11 = Postscaled internal clock (INTRC/INTOSC derived)
// periferc idem as FOSC
OSCCON.SCS1=1;
OSCCON.SCS0=1;
while(OSCCON.OSTS==0);
Hardware_Init();
ADC_Init();
Delay_ms(250);
// Initialize variables
k=0;
tmp = 0;
Vbray=0;
i = 0;
UART1_Init(19200);
UART1_Write(CLS);
Delay_ms(500);
CRLF1();
UART1_Write_CText("Projet : "Projet"\r\n");
UART1_Write_CText(Source"_"Version"c\r\n");
UART1_Write_CText("FOSC interne 8Mhz USB at 48MHz\r\n");
UART1_Write_CText("Uart1 19200 bds = Espion/debugging \r\n");
UART1_Write_CText("TEST envoi page HTML > 256 cars\r\n");
UART1_Write_CText("Page Web 768 cars maxi\r\n");
CRLF1();
RAZ_UART1();
txt=&TEXTE[0];
CRLF1();
UART1_Write_CText("\r\n TEST PAGE HTML \r\n");
// refresh Datas
EA1=ADC_Read(1);
Degres1=(float)EA1*330/1024; // 10mV par degres C
sprintf(txt,"% 2.2f",Degres1);
memcpy(WebVar0+17,txt,5);
EA2=ADC_Read(2);
Degres2=(float)EA2*330/1024; // 10mV par degres C
sprintf(txt,"% 2.2f",Degres2);
memcpy(WebVar1+17,txt,5);
WebVar2[6]=BP1+48;
WebVar3[6]=BP2+48;
// build WebPage
strConstRamCpy(WebPage,WebHead);
k=strlen(WebPage);
WordToStr(k,CRam1);
UART1_Write_CText("1_ ");UART1_Write_Text(CRam1);CRLF1();
strcat(WebPage+k,WebVar0);
k=strlen(WebPage);
WordToStr(k,CRam1);
UART1_Write_CText("2_ ");UART1_Write_Text(CRam1);CRLF1();
strcat(WebPage+k,WebVar1);
k=strlen(WebPage);
WordToStr(k,CRam1);
UART1_Write_CText("3_ ");UART1_Write_Text(CRam1);CRLF1();
strcat(WebPage+k,WebVar2);
k=strlen(WebPage);
WordToStr(k,CRam1);
UART1_Write_CText("4_ ");UART1_Write_Text(CRam1);CRLF1();
strcat(WebPage+k,WebVar3);
k=strlen(WebPage);
WordToStr(k,CRam1);
UART1_Write_CText("5_ ");UART1_Write_Text(CRam1);CRLF1();
strcat(WebPage+k,WebVar4);
k=strlen(WebPage);
WordToStr(k,CRam1);
UART1_Write_CText("6_ ");UART1_Write_Text(CRam1);CRLF1();
strConstRamCpy(WebPage+k,WebTail);
IPD=48;
strConstRamCpy(msg,"AT+CIPSEND=x,");
msg[11]= IPD;
k=strlen(msg);
PageLen=strlen(WebPage);
WordToStr(PageLen,CRam1);
strcat(msg+k,Ltrim(CRam1));
UART1_Write_CText("Envoi msg : ");
UART1_Write_Text(msg);CRLF1();
UART1_Write_CText("\r\n\r\nVersion avec 2 envoi separé de 2 demi WebPage =OK \r\n");
for (i=0;i<PageLen/2;i++) UART1_Write(WebPage[i]);
for (i=PageLen/2;i<PageLen;i++) UART1_Write(WebPage[i]);
CRLF1();
UART1_Write_CText("\r\n\r\nFin du test #1 \r\n");
// L=284 //OK si envoi en 2 passes
UART1_Write_CText("\r\n\r\nVersion avec 1 seul envoi de Webpage complet = problemo \r\n");
UART1_Write_Text(WebPage);
CRLF1();
// problemo
// L=258 cars ????? au lieu de 284 si envoi en 1 seule foisfor (i=0;i<PageLen/2,i++) UART1_Write(WebPage[i
UART1_Write_CText("\r\n\r\nFin du test #2 \r\n");
while(1);
}
et les 2 resultats correspondants : envoi en 2 fois ou envoi en 1 fois => plantage
TEST PAGE HTML
1_ 170
2_ 200
3_ 230
4_ 241
5_ 252
6_ 265
Envoi msg : AT+CIPSEND=0,284
Version avec 2 envoi separé de 2 demi WebPage =OK
<html><head><meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="10"><title>WIFI3-
Click</title></head><body><h2><br>Temper. Ext :<br> 55.74 °C<br>Temper. Amb :<br> 168.3 °C<br>BP1 = 1<br>BP2 = 1<br>Idx = xxx<br></h2></body></html>
Fin du test #1 Taille texte=286 - CRLF => 284 cars ..OK
Version avec 1 seul envoi de Webpage complet = problemo
<html><head><meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="10">
<title>WIFI3-Click</title></head><body><h2><br>Temper. Ext :<br> 55.74 °C<br>Temper. Amb :<br> 168.3 °C<br>BP1 = 1<br>BP2 =
1<br>Idx <html><head><meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1"><meta http-equiv="refresh"
content="10"><title>WIFI3-Click</title></head><body><h2><br>Temper. Ext :<br> 55.74 °C<br>Temper. Amb :<br> 168.3 °C<br>BP1 =
1<br>BP2 = 1<br>Idx <html><head><meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1"><meta http-equiv="refresh"
content="10"><title>WIFI3-Click</title></head><body><h2><br>Temper. Ext :<br> 55.74 °C<br>Temper. Amb :<br> 168.3 °C<br>BP1 = 1
<br>BP2 = 1<br>Idx <html><head><meta http-equiv="Content-


