encore un bug sur MikroC et ce PIC16F1619
en suivant la datasheet de ce pIC
j'ai pu (assez) facilement utiliser l'UART1 Hardware , en m'appuyant sur le MPLABX MCC ausssi !
UART1 Mappé sur B7 TX et B5 RX .
je vous mets le code associé ( avec au passage la config pur I2C1 Hardware sur RB4=SDA , RB6=SCL)
Code : Tout sélectionner
void Config_PPS(void)
{
Unlock_IOLOCK();
// USART1 RX, TX
// ---------- Peripheral PIN and EUSART configuration ----------------------
// PPS_Mapping(char rp_num, char input_output, char funct_name);
// PPS_Mapping(RB7, _OUTPUT, _TX_CK);
// PPS_Mapping(RB5, _INPUT, _RXPPS);
// use direct
RB5PPS = 0x0D; // RX RB5
RB7PPS= 0x12; // TX RB7
// --- I2C ----------------------
// PPS_Mapping(RB4 , _OUTPUT, _SDA);
// PPS_Mapping(RB6 , _OUTPUT, _SCK_SCL); // Sets RB6 SCL I2C
// TABLE 13-2: AVAILABLE PORTS FOR OUTPUT BY PERIPHERAL
// REGISTER 13-2: RxyPPS: PIN Rxy OUTPUT SOURCE SELECTION REGISTER
// bit 7-5=0 bit 4-0 RxyPPS<4:0>: Pin Rxy Output Source Selection bits
RB6PPS = 0x10; // 0b00010000; // 16 RB6->MSSP:SCL
RB4PPS = 0x11; //0b00010001; // 17 RB4->MSSP:SDA;
// TABLE 13-1: PPS INPUT REGISTER RESET VALUES
// SPI and I2C clock SSPCLKPPS RB6
SSPCLKPPS = 0x0E; //RB6->MSSP:SCL;
// SPI and I2C data SSPDATPPS RB4
SSPDATPPS = 0x0C; //RB4->MSSP:SDA;
Lock_IOLOCK();
}
exemple d'usage UART1
Code : Tout sélectionner
txt=&TEXTE[0];
UART1_Remappable_Init(19200);
UART1_Write_CText(" Init UART1 Remappable RB7=TX RB5=RX \r\n");
strConstRamCpy(txt,"ABCDEFGHIJKLMNOPQRSTUVWXYZ..etc\rn");
UART1_Remappable_Write_Text(txt);
Delay_ms(100);
CRLF1() ;
mais j'ai voulu en savoir plus sur la fonction UART1_MapDefaultPins()
NON RENSEIGNE dans la librairie System UART_Remappable
d'apres les dire de MIKROE
You should use UART1_Remappable_Init instead of UART1_Init which maps UART to the default pins (RC4, RC5).
un test rapide montre que ça ne marche pas !
et si on regarde bien la datasheet
RC4 et RC5 sont affecté plutot au modele de PIC 14-16Pins 16F1619 ou 16F1615
alors que le pur le 16F1619 20 PINS c'est bien RB5 et RB7
d'ou la question à MikroE
did you tested this function by yourself ?
Hi Paul,
I've just tested this. The _TX_CK constant is wrong, therefore, UART1_MapDefaultPins
functions maps TX pin wrong. I'll forward this to our developers.
To get it to work on RC5, RC4, you need to set HIDC pins in HIDRVC register
and map the UART pins manually:
voici la contre mesure proposée ...
Code : Tout sélectionner
HIDRVC = 0x30;
Unlock_IOLOCK();
PPS_Mapping_NoLock(_RC4, _OUTPUT, 18);
PPS_Mapping_NoLock(_RC5, _INPUT, _RXPPS);
Lock_IOLOCK();
je vais la tester et rendre compte sur ce post ... à suivre