Bonjour
Avec un pic 18F252, le programme ci-dessous tente d'afficher un message via la fonctionnalié USART.
La tentative via la fonction putsUSART() est OK et lève le doute sur un défaut matériel ou un mauvais réglage du terminal (PC/KTTY : 9600B, 8bits, 1Stop, pas de controle de flux).
La tentative via printf() n'affiche rien.
Voyez vous une piste ? J'ai cherché du coté de stdout sans succès.
// 18F252 Test USART and printf
#include <plib/usart.h>
#include <stdio.h>
#pragma config OSC = HS
#pragma config PWRT = OFF
#pragma config LVP = OFF
#pragma config WDT = OFF,DEBUG=OFF
void main() {
char x[10];
int n=0;
int a;
TRISC=0;
OpenUSART(USART_TX_INT_OFF & USART_RX_INT_ON &
USART_ASYNCH_MODE & USART_EIGHT_BIT &
USART_CONT_RX & USART_BRGH_LOW, 31);
printf("Hello, world by prinf !\n"); // ==> Not display
putsUSART("Hello, world by putsUSART !\n"); // ==> Display OK
while(1);
}
La version de MPLAB
/*
Product Version: MPLAB X IDE v2.00
Java: 1.7.0_25; Java HotSpot(TM) Client VM 23.25-b01
System: Windows 7 version 6.1 running on x86; Cp1252; fr_FR (mplab)
Userdir: C:\Users\jhl\AppData\Roaming\. mplab_ide\dev\v2.00
*/
Le résultat de compilation
/*
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Users/jhl/Documents/Software_UART/s3.X'
make -f nbproject/Makefile-default.mk dist/default/production/s3.X.production.hex
make[2]: Entering directory `C:/Users/jhl/Documents/Software_UART/s3.X'
"C:\Program Files\Microchip\xc8\v1.30\bin\ xc8.exe" --pass1 --chip=18F252 -Q -G --double=24 --float=24
--emi=wordwrite --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255
--warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032
--runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib --output=-mcof,+elf:multilocs
--stack=compiled:auto:auto:auto "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning:
(%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -obuild/default/production/newmain.p1 newmain.c
newmain.c:18: warning: (359) illegal conversion between pointer types
pointer to const unsigned char -> pointer to unsigned char
"C:\Program Files\Microchip\xc8\v1.30\bin\ xc8.exe" --chip=18F252 -G -mdist/default/production/s3.X.production.map --double=24 --float=24 --emi=wordwrite --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s" -odist/default/production/s3.X.production.elf build/default/production/newmain.p1
Microchip MPLAB XC8 C Compiler (Free Mode) V1.30
Copyright (C) 2014 Microchip Technology Inc.
License type: Node Configuration
:: advisory: (1233) Employing 18F252 errata work-arounds:
:: advisory: (1234) * Address 4000h boundary
:: advisory: (1234) * Faulty table reads at -40 degrees C
:: advisory: (1234) * GOTO instruction at reset vector must be preceded by NOP
:: advisory: (1234) * Peripherals can misbehave if BSR = 15
:: advisory: (1234) * DAW instruction may improperly clear CARRY bit
:: advisory: (1234) * Specifically disable interrupt sources during tblwt instruction
:: advisory: (1234) * Writes to flash must target opposite side of 4000h boundary
:: warning: (1273) Omniscient Code Generation not available in Free mode
:: warning: (1311) missing configuration setting for config word 0x300005, using default
:: warning: (1311) missing configuration setting for config word 0x300008, using default
:: warning: (1311) missing configuration setting for config word 0x300009, using default
:: warning: (1311) missing configuration setting for config word 0x30000A, using default
:: warning: (1311) missing configuration setting for config word 0x30000B, using default
:: warning: (1311) missing configuration setting for config word 0x30000C, using default
:: warning: (1311) missing configuration setting for config word 0x30000D, using default
Memory Summary:
Program space used 16Ah ( 362) of 8000h bytes ( 1.1%)
Data space used 8h ( 8) of 600h bytes ( 0.5%)
Configuration bits used 7h ( 7) of 7h words (100.0%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
ID Location space used 8h ( 8) of 8h bytes (100.0%)
Data stack space used 0h ( 0) of 580h bytes ( 0.0%)
Running this compiler in PRO mode, with Omniscient Code Generation enabled,
often produces code which is 60% smaller and at least 400% faster than in
Free mode. The MPLAB XC8 PRO compiler output for this code could be
202 bytes smaller and run 4 times faster.
See http://www.microchip.com for more information.
make[2]: Leaving directory `C:/Users/jhl/Documents/Software_UART/s3.X'
make[1]: Leaving directory `C:/Users/jhl/Documents/Software_UART/s3.X'
BUILD SUCCESSFUL (total time: 16s)
Loading code from C:/Users/jhl/Documents/Software_UART/s3.X/dist/default/production/s3.X.production.hex...
Loading symbols from C:/Users/jhl/Documents/Software_UART/s3.X/dist/default/production/s3.X.production.elf...
Loading completed
*/
JHL
Cordialement
-----