version 0.0 : 25/01/2020
rev 23/03/2020......



Présentation Test du PIC 16F1619 (Janvier 2020)
Test Afficheur OLED (Janvier 2020)
Un thermometre Corporel avec capteur Inox DS18B20 (mars 2020)






Présentation du TEST PIC 16F1619 :

en connectique Dip20
FOSC interne : 16MHz

HARDWARE Prototype :

images/t_Proto_16F1619.gif
prototype Breadboard


click to enlarge Prototype picture
auto alimenté via le Pickit4 !

void Init_Fosc(void)
{

// internal FOSC
/*
bit 7 SPLLEN: Software PLL Enable bit
bit 6-3 IRCF<3:0>: Internal Oscillator Frequency Select bits
1111 =16 MHz HF
1110 =8 MHz HF
1101 =4 MHz HF
1100 =2 MHz HF
1011 =1 MHz HF
1010 =500 kHz HF(1)
1001 =250 kHz HF(1)
1000 =125 kHz HF(1)
0111 =500 kHz MF (default upon Reset)
0110 =250 kHz MF
0101 =125 kHz MF
0100 =62.5 kHz MF
0011 =31.25 kHz HF(1)
0010 =31.25 kHz MF
000x =31 kHz LF
bit 2
bit 1-0 SCS<1:0>: System Clock Select bits
*/
OSCCON=0;
// 16 MHZ
OSCCON.IRCF3=1;
OSCCON.IRCF2=1;
OSCCON.IRCF1=1;
OSCCON.IRCF0=1;
// 1x = Internal oscillator block
OSCCON.SCS1=1;
OSCTUNE=0;
}




Config bits
CONFIG1 : $8007 : 0x38E4
CONFIG2 : $8008 : 0x1E83
CONFIG3 : $8009 : 0x3F1F



Available RAM: 1024 [bytes], Available ROM: 8192 [Word])


Schéma de test et Pinout




Hardware :



sbit Led_Rouge at LATA.B4;
sbit Led_Rouge_Dir at TRISA.B4;
sbit SQA at LATC.B3;
sbit SQA_Dir at TRISC.B3;


Test de L' UART1 Hardware

datasheet 16F1619_40001770C.pdf
.

Affectation des Pins pour la fonction UART1 Hardware via PPS
images/RB5_RB7_USART_on_DIP20-pins.jpg

Configuraion PPS

Unlock_IOLOCK();
// sorties Classiques
RC3PPS=0; // pour SQA
RA4PPS=0; // pour Led Rouge
RC4PPS=0;
RC5PPS=0; // Pour Led Verte

// 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
Lock_IOLOCK();


Usage de la librarie system :
UART_Remappable Library

Init :
UART1_Remappable_Init(19200);
*ex: envoi un caractere
UART1_Remappable_Write('A');
*ex: envoi un texte, avec txt= pointeur char initialisé sur :
unsigned char TEXTE[80];
txt=&TEXTE[0];
strConstRamCpy(txt,"Hello World\r\n");
UART1_Remappable_Write_Text(txt);

*Traitement Interruption :
void Interrupts() iv 0x0004 ics ICS_AUTO
{
if ( (RCIE_bit==1) && ( RCIF_bit==1))
{ ..
voir source




SOFTWARE :
projet :
_16F1619_Test_UART1_RB7_TX_RB5_RX_I2C_RB6_SCL_RB4_SDA_2020_02_08.zip
Source main :
_16F1619_Test_UART1_RB7_TX_RB5_RX_I2C_RB6_SCL_RB4_SDA_2020_02_08.c
Oled lib :
OLED_128x32_I2C1_remappable_16F1619_2020.mcl
header :
OLED_128x32_I2C1_remappable_16F1619_2020_.h


Une autre Config UART sur pins RC4 =TX et RC5=RX (avec 16F69 DIP20)



(attention Bug MikroC !)
la fonction " UART1_MapDefaultPins();" devrait s'en charger !
MAIS NON !


partie PPS (Peripheral PIN Setting):

Unlock_IOLOCK();
// USART1 RX, TX
// ---------- Peripheral PIN and EUSART configuration ----------------------
PPS_Mapping_NoLock(_RC4, _OUTPUT,
18); // .<--------------------------------correctif !
PPS_Mapping_NoLock(_RC5, _INPUT, _RXPPS);
// --- I2C ----------------------
// PPS_Mapping(RB4 , _OUTPUT, _SDA);
// PPS_Mapping(RB6 , _OUTPUT, _SCK_SCL); // Sets RB6 SCL I2C

// --- partie pour I2C1 -----
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: I2C PPS INPUT REGISTER RESET VALUES
SSPCLKPPS = 0x0E; //RB6->MSSP:SCL;
SSPDATPPS = 0x0C; //RB4->MSSP:SDA;

RC6PPS=0; // sortie SQA
Lock_IOLOCK();



puis init via:
UART1_Remappable_Init(19200);
testé OK




Test du LCD I2C OLED 128x32 (controleur SSD1306)


L'afficheur graphique OLED 128x32 :







I2C1 Remappable Hardware init RB4=SDA RB6=SCL
I2C1_Remappable_Init(400000);
I2C1_SetTimeoutCallback(10, I2C1_TimeoutCallback);
I2C_Set_Active(&I2C1_Remappable_Start, &I2C1_Remappable_Repeated_Start,
_&I2C1_Remappable_Rd, &I2C1_Remappable_Wr, &I2C1_Remappable_Stop, &I2C1_Remappable_Is_Idle);
while( I2C1_Is_Idle()==0);

modif pour CHECK presence device :

ACKSTAT Status Flag
In Transmit mode, the ACKSTAT bit of the SSPxCON2 register is cleared when the slave has sent an Acknowledge
(ACK = 0) and is set when the slave does not Acknowledge (ACK = 1). A slave sends an Acknowledge
when it has recognized its address (including a general call), or when the slave has properly received its data

Test avec Ikalogic SQA50 Analyser sur bus I2C
pour verifier la réponse ACK à l'adresse 0x78 =OLED LCD

images/t_SQA_analyse_I2C_adressage.gif


unsigned char check_device(unsigned char dev_address)
{
char Etat;
Etat=0;
ACKSTAT_bit=0;
SQA=1; // pour synchro analyser logique
I2C1_Remappable_Start();
SQA=0;
_asm nop;
SQA=1;
Etat= I2C1_Remappable_Wr(dev_address);
if(ACKSTAT_bit )
{
UART1_Remappable_Write('.'); //_CText(" is not found\r\n");
}
else
{
strConstRamCpy(txt,"\r\n Device at adresse : ");
k=strlen(txt);
ByteToStr(dev_address,CRam1);
strcat(txt+k,CRam1);
UART1_Remappable_Write_Text(txt);
UART1_Write_CText(" found OK\r\n");
Etat++;
}
I2C1_Remappable_Stop();
SQA=0;
return Etat;
}


Usage :

for (i=60;i<254;i=i+2) c1= check_device(i) ;

ce qui donne comme resultat sur le terminal:

..............................
Device at adresse : 120 found OK
..................................................................

120 =0x78 .. le LCD OLED est bien vu !


Le test affichage LCD OLED est OK
, mais ce PIC16F1619
manque de ROM et RAM pour l'exploiter à fond
=> pas d'affichage image *BMP
=> pas de lettres minuscules avec fonte 8x16
mais char taille 3 uniquement pour les chiffres en gros caracteres "0123456789. °"

En comparaison
*PIC18F26K22 :  
PDIP28 ROM : 32 768 .. RAM : 3896 ..... EEPROM ....1024
PIC16F1847 :  ROM : 14K RAM : 1K , EEPROM: 256
PIC16F1619 :   PDIP20 ROM : 8 192 .... RAM: 1024 ...EEprom 0 ! mais High Endurance Flash 128 bytes???
* discontinued...sera remplacé par PIC18F26Q10

Conclusion :
Un OLED grafique necessite beaucoup de ressources!
pic moyennement interessant pour cette application
mais à recommander pour remplacer un 16F628 ou 16F688


Ce PIC16F1619 n'est pas géré par le pickit3, necessite donc un Pickit4 pour etre programmé! (+ MPLAB IPE)
Nota:
vu la tres faible consommation du PIC + OLED < à 10mA, v
j'utilise le PICKIT4 pour alimenter le montage via VDD

MAIS :
ATTENTION
si RX UART est connecté et que le PICKIT4 alimente le montage, on obtient ce message d'alarme :
You are attempting to power your target from the tool.
Ensure you do not have other source of power on your target

We have detected some residual VDD voltage at the connector interface.
Connection Failed.

2020-01-28 17:16:49 +0100 - Programming...
=> deconnecter la liaison Cable Prolific (fil vert) TTL/USB <->PC, de la pin RX du PIC

Connecting to MPLAB PICkit 4...

Currently loaded versions:
Application version............00.05.41
Boot version...................01.00.00
Script version.................00.03.33
Script build number............0540a22e50
PICkit 4 is supplying power to the target (4,00 volts).
Target device PIC16F1619 found.
Device Revision Id = 0x2004
Calculating memory ranges for operation...
Erasing...
The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x1f9f
configuration memory
Programming/Verify complete
2020-01-30 17:52:27 +0100 - Programming complete




Software : MikroC (version 7.60 ) :

Projet zipé: _16F1619_Test_UART1_RC4_TX_RC5_RX_I2C_2020_01_30.zip
Used RAM (bytes): 1006 (100%)
Free RAM (bytes): 2 (0%)
Used ROM (program words): 7909 (97%)
Free ROM (program words): 283 (3%)
Source :
_16F1619_Test_UART1_RC4_TX_RC5_RX_I2C_2020_01_30.c
Chargeur :
Test_16F1619_OLED_LCD_I2C_UART_RC4_RC5_2020_01_30.hex



Thermometre Corporel à base de DS18B20 ( et 16F1619)

Usage d'un afficheur OLED 132x32 ( précédement decrit)
Bus OWS sur PIN RC0 pour le capteur DS18B20
Ce PIC n' a pas assez de taille FLASM ROM ==> Reduction drastique de l'espace occupé par les Fontes caracteres,
pour ne conserver que la Taille 2 et 3
afin d'avoir un affichage maximal de la valeur de temperature .
La mesure est aussi envoyée sur l'UART .. RB7=TX donc possible de la recuperer via bluetooth
Affichage sur 4 digits
La Led Bleue sur RC5, clignote pour signaler Temperature inférieure à la normale
La Led rouge sur RA4 clignote pour signaler Temperature au dessus de la normale
sinon , les 2 diodes leds clignotent ensemble, si la temperature est dans la bonne gamme ( 37,5 + - 0,8 )
Un OFFSET d'etalonnage serait un plus ..
A suivre .. gestion de la zone de 128 bytes dispo dans High Endurance Flash ..
adresse 0x1F80 ..0x1FFF
Nota: Programmation du 16F1619 via MPLAB IPE V5.0 et PICKIT4.


Schema :



Prototype :

images/Proto_Themo_Corporel_16F1619_200323.jpg


Circuit Imprimé :

Thermometre_Corporel_16F1619_DS18B20_sans_PM.lay6

images/t_Thermo_Corporel_16F1619_Circuit_Imprime.gif images/t_Thermo_Corporel_16F1619_Circuit_Photo.gif
   


SOFTWARE application (mikroC)
Projet : _Thermometre_Corporel_2020_03.zip
Chargeur : Thermometre_Corporel_16F1619_OLED_DS18B20_2020_03_22.hex
Source : Thermometre_Corporel_16F1619_UART1_RB7_TX_RB5_RX_I2C_RB6_SCL_RB4_SDA_DS18B20_RC2_2020_03_22.c


Résultats

Presentation :

Projet : Test_16F1619_OLED_LCD_128x32_I2C_RB4_SCL_RB6_SDA_UART_RB7_TX_RB5_RX_DS18B20_RC2_2020_03_21.mcppi
Source : _16F1619_Test_UART1_RB7_TX_RB5_RX_I2C_RB6_SCL_RB4_SDA_DS18B20_RC2_2020_03_21.c

I2C1 Hardw.init RB4=SDA RB6=SCL
OLED SSD1306 128x32 I2C, init. en mode 2
Test Sonde OWS DS18B20 sur RC2
Family Code : 28 ID1 = AA56C1381401 CRC= 40

85.000
DS18B20= 85.000°C 138346506
DS18B20= 34.625°C 47500
DS18B20= 34.562°C -2875



DS18B20= 38.000°C 625
DS18B20= 37.875°C 500
DS18B20= 37.812°C 375
DS18B20= 37.687°C 312
DS18B20= 37.562°C 187
DS18B20= 37.500°C 62
DS18B20= 37.437°C 0
DS18B20= 37.312°C -63
DS18B20= 37.250°C -188
DS18B20= 37.187°C -250
DS18B20= 37.062°C -313
DS18B20= 37.000°C -438
DS18B20= 36.875°C -500
DS18B20= 36.750°C -625


















paulfjujo@free.fr


../common/GIF/LTC1286p.jpg



Retour à l'index general