Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Easypic fusion v7 - DSPIC33EP512MU810 - RTC 5 click

Status
Not open for further replies.

GiorgioLyons

Newbie level 3
Joined
Jun 15, 2018
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
90
MCU: DSPIC33EP512MU810
Dev.Board: Easypic fusion v7
Click board: RTC5 click ( MCP79510, a real-time clock/calendar with an SPI interface)
placed in clicker 2 socket

SW: mikroC PRO for PIC
DEBUG HARDWARE MIKROE PROG/DEBUGGER
COMP VERSION 7.1.0


Hi guys, im developping a firmware for a DSPIC33EP512MU810, my goal is to generate time data and then send the data to computer by uart using hc 05 bluetooth module.
The time data shoul be generated by RTC5 click placed in socket 2 of Easypic fusion v7 board.


Here there is the Configuration Register

Code:
FGS     : $F80004 : 0x0003
FOSCSEL : $F80006 : 0x0083
FOSC    : $F80008 : 0x0085
FWDT    : $F8000A : 0x007F
FPOR    : $F8000C : 0x001F
FICD    : $F8000E : 0x00D7
FAS     : $F80010 : 0x0003


and the code



Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/*
 * Project name:
      RTC5 click (Reading/Writing time data to MCP79510 through SPI)
 * Description:
     This is a sample program which demonstrates the use of the Microchip's
     MCP79510 Real-Time Clock Calendar. The time is inputted to the MCP79510
     via SPI
 * Test configuration:
     MCU:             P33EP512MU810
     Dev.Board:       EasyPIC fusion v7
 
     Oscillator:      HS-PLL 32.0000 MHz, 8.0000 MHz Crystal
     ext. modules:    rtc5 click -
                      ble3 click
     SW:              mikroC PRO for PIC
 * NOTES:
     - RTC5 click board is in the the mikroBUS socket 2 on the EasyPIC fusion v7 board.
 
 
*/
 
#include <built_in.h>
#include <stdint.h>
 
// RTC Commands
#define EEREAD  0x03
#define EEWRITE 0x02
#define EEWRDI  0x04
#define EEWREN  0x06
#define SSREAD  0x05
#define SRWRITE  0x01
#define READ  0x13
#define WRITE  0x12
#define UNLOCK  0x14
#define IDWRITE  0x32
#define IDREAD  0x33
#define CLRRAM  0x54
 
//time and configuration registers
#define MILISECONDS_REGISTERS      0x00
#define SECONDS_REGISTER           0x01
#define MINUTES_REGISTER           0x02
#define HOURS_REGISTER             0x03
#define DAY_REGISTER               0x04
#define DATE_REGISTER              0x05
#define MONTH_REGISTER             0x06
#define YEAR_REGISTER              0x07
#define STATUS_REGISTER            0x08
#define CALIBRATION                0x09
 
//alarm 0 Registers
#define ALARM0_SECONDS_REGISTER           0x0C
#define ALARM0_MINUTES_REGISTER           0x0D
#define ALARM0_HOURS_REGISTER             0x0E
#define ALARM0_DAY_REGISTER               0x0F
#define ALARM0_DATE_REGISTER              0x10
#define ALARM0_MONTH_REGISTER             0x11
 
//alarm 1 Registers
#define ALARM1_SECONDS_REGISTER           0x12
#define ALARM1_MINUTES_REGISTER           0x13
#define ALARM1_HOURS_REGISTER             0x14
#define ALARM1_DAY_REGISTER               0x15
#define ALARM1_DATE_REGISTER              0x16
#define ALARM1_MONTH_REGISTER             0x17
 
// RTC5 click module connections
sbit Chip_Select at LATC4_bit;  // this is where Chip_Select is fully defined
//sbit Chip_Select at RC4_bit;
sbit Chip_Select_Direction at TRISC4_bit; // this is where Chip_Select_Direction is fully defined
 
unsigned char read_array[16];
unsigned char txtSec[12];
unsigned char txtMin[12];
unsigned char txtHour[12];
unsigned char hours;
unsigned char minutes;
unsigned char seconds;
 
 
 
//clear RTCC and SRAM memory
void Clear(void)
{
   //Clear RTCC memory
   int i;
  for(i=0;i<0x20;i++)
  {
    Chip_Select = 0;
    SPI1_Write(WRITE);
    SPI1_Write(i);
    SPI1_Write(0x00);
    Chip_Select = 1;
    delay_us(1);
  }
  //Clear SRAM memory
  Chip_Select = 0;
  SPI1_Write(CLRRAM);
  Chip_Select = 1;
  delay_us(1);
 
 
 
}
// Set RTC time
void SetTime(int seconds, int minutes, int hours) {
 
   // Write seconds into RTC
  Chip_Select = 0;
  SPI1_Write(WRITE);
  SPI1_Write(SECONDS_REGISTER);
  SPI1_Write(seconds);
  Chip_Select = 1;
  delay_us(1);
 
  // Write minutes into RTC
  Chip_Select = 0;
  SPI1_Write(WRITE);
  SPI1_Write(MINUTES_REGISTER);
  SPI1_Write(minutes);
  Chip_Select = 1;
  delay_us(1);
 
    // Write hours into RTC
  Chip_Select = 0;
  SPI1_Write(WRITE);
  SPI1_Write(HOURS_REGISTER);
  SPI1_Write(hours);
  Chip_Select = 1;
  delay_us(1);
}
 
void Start_RTC(void)
{
  //buffer seconds register
  unsigned char temp;
  Chip_Select = 0;
  SPI1_Write(READ);
  SPI1_Write(SECONDS_REGISTER);
  temp =  SPI1_Read(0);
  Chip_Select = 1;
  delay_us(1);
 
  //set ST bit
  Chip_Select = 0;
  SPI1_Write(WRITE);
  SPI1_Write(SECONDS_REGISTER);
  SPI1_Write(temp|0x80);
  Chip_Select = 1;
  delay_us(1);
 
  temp = 0;
 //check if oscillator is running
 while(temp&0x20 == 0)
  {
  Chip_Select = 0;
  SPI1_Write(READ);
  SPI1_Write(DAY_REGISTER);
  temp =  SPI1_Read(0);
  Chip_Select = 1;
  delay_us(1);
  }
  // OSCON = 1; //light up OSCON diode    not defined
 
  //set VBATEN bit
  Chip_Select = 0;
  SPI1_Write(WRITE);
  SPI1_Write(DAY_REGISTER);
  SPI1_Write(temp|0x08);
  Chip_Select = 1;
  delay_us(1);
}
 
 
// Read time from the RTC
void ReadTime() {
  Chip_Select = 0;
  SPI1_Write(READ);
  SPI1_Write(SECONDS_REGISTER);
  read_array[0] = SPI1_Read(0);      // Read seconds    
  read_array[1] = SPI1_Read(0);      // Read minutes    
  read_array[2] = SPI1_Read(0);      // Read hours      
  Chip_Select = 1;
  delay_us(1);
}
 
// Format time
void FormatTime() {
  // Format seconds, minutes and hours
  read_array[0] = Bcd2Dec(read_array[0] & 0x7F);
  read_array[1] = Bcd2Dec(read_array[1] & 0x7F);
  read_array[2] = Bcd2Dec(read_array[2] & 0x7F);
 
  // Convert seconds, minutes and hours to string
  ByteToStr(read_array[0], txtSec);
  ByteToStr(read_array[1], txtMin);
  ByteToStr(read_array[2], txtHour);
 
  // Trim leading spaces
  Ltrim(txtSec);
  Ltrim(txtMin);
  Ltrim(txtHour);
}
 
void Tone() {
  Sound_Play(450, 200);   // Frequency = 659Hz, duration = 250ms
}
 
 
  void main () {
  
  // Setting output frequency to 140MHz
  PLLFBD = 70;             // PLL multiplier M=70
  CLKDIV = 0x0000;         // PLL prescaler N1=2, PLL postscaler N2=2
  
  // Set all pins as digital
  ANSELA = 0x00;           // Convert all I/O pins to digital
  ANSELB = 0x00;
  ANSELC = 0x00;
  ANSELD = 0x00;
  ANSELE = 0x00;
  ANSELG = 0x00;
 
  Chip_Select_Direction = 0;         // Set chip select pin direction
  LATC4_bit=1;
  // Chip_Select = 1;
  delay_us(10);
 
/*OSCON_Direction = 0;
  OSCON = 0;*/
 
  Sound_Init(&PORTD, 3);
  Delay_ms(100);
  Tone();
  Delay_ms(100);
   
  PPS_Mapping(100, _INPUT,  _U1RX);              // Sets pin RP100  RF4 to be Input, and maps U1RX to it
  PPS_Mapping(101, _OUTPUT, _U1TX);              // Sets pin RP101  RF5 to be Output, and maps U1TX to it
  
  UART1_Init(115200);              // Initialize UART module at 56000 bps
  Delay_ms(500);                 // Wait for UART module to stabilize
  
  Unlock_IOLOCK();
  PPS_Mapping_NoLock(98, _OUTPUT, _SDO1);     // Set pin MISO RF2 to be Output, and map SD03 to it
  PPS_Mapping_NoLock(79, _OUTPUT, _SCK1OUT);  // Set pin SCK RD15 to be Output, and map SCK3 to it
  PPS_Mapping_NoLock(104, _INPUT,  _SDI1);     // Set pin MOSI RF8 to be Input,  and map SDI3 to it
  Lock_IOLOCK();
 
  // Initalize SPI module
  SPI1_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_1, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE);
  //SPI1_Init();
/*SPI1_Remappable_Init_Advanced(_SPI_REMAPPABLE_MASTER_OSC_DIV16, _SPI_REMAPPABLE_DATA_SAMPLE_MIDDLE, _SPI_REMAPPABLE_CLK_IDLE_LOW, _SPI_REMAPPABLE_LOW_2_HIGH);
  SPI_Set_Active(&SPI1_Remappable_Read, &SPI1_Remappable_Write);*/
  SPI_Set_Active(&SPI1_Read, &SPI1_Write);
 
  // Set time
  //Clear();
  SetTime(0x00,0x00,0x05);
  Start_RTC();
 
  while(1){
    ReadTime();                      // Read time
    FormatTime();                    // Format time
    //DisplayTime();                   // Display time
    
 ;
 
      //IntToStr(0,txtHour);
      UART1_Write_Text(txtHour);
      UART1_Write_Text(";");
      
      //IntToStr(0,txtMin);
      UART1_Write_Text(txtMin);
      UART1_Write_Text(";");
      
      //IntToStr(0,txtSec);
      UART1_Write_Text(txtSec);
      UART1_Write_Text(";");
    
      UART1_Write_Text("Time0.1");
      UART1_Write_Text(";");
      UART1_Write(13);       // new line
      UART1_Write(10);       // return
    
    Delay_ms(100);
 
  }
}




The Hc-05 module looks working good

The problem is that im sending to computer the same string , so im afraid the RCT5 module is not working.

I dont know where could be the problem, some wrong configuration pin or some wrong command.

Could you help me please ?



this is the the data i receive in the uasart terminal


85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;

85;85;85;Time0.1;


I noticed in the data received

85;85;85;Time0.1;
the value 85 changes if i change 0x7F in

Code: Select all
Code:
read_array[0] = Bcd2Dec(read_array[0] & 0x7F);


Thank you in advance
 

Is it true ?

SW: mikroC PRO for PIC

or Is it

SW: mikroC PRO for dsPIC ?
 

Pardon, my mistake.

yes it is mikroC PRO for dsPIC
 

In line 78 you have declared uninitialized the variable seconds (by default it is likely set to `Zero` after power up or reset), whereas according to the datasheet (page 17), in order to start the RTC oscillator, you must set the bit 7 of the register RTCSEC (address 0x01) to `1`. In other words, you should add to Init() do something like this to run just once:

Code:
SPI1_Write (0b10000000 | seconds);

PS: Having a better look, perhaps you have to do that after all values updated to the address RTCSEC.
 

Thank you for help andre_teprom

I modified a bit the code

Code:
  /*
 * Project name:
      RTC5 click (Reading/Writing time data to MCP79510 through SPI)
 * Description:
     This is a sample program which demonstrates the use of the Microchip's
     MCP79510 Real-Time Clock Calendar. The time is inputted to the MCP79510
     via SPI
 * Test configuration:
     MCU:             P33EP512MU810
     Dev.Board:       EasyPIC fusion v7

     Oscillator:      HS-PLL 32.0000 MHz, 8.0000 MHz Crystal
     ext. modules:    rtc5 click -
                      ble3 click
     SW:              mikroC PRO for PIC
 * NOTES:
     - RTC5 click board is in the the mikroBUS socket 2 on the EasyPIC fusion v7 board.

*/

#include <built_in.h>
#include <stdint.h>

// RTC Commands
#define EEREAD  0x03
#define EEWRITE 0x02
#define EEWRDI  0x04
#define EEWREN  0x06
#define SSREAD  0x05
#define SRWRITE  0x01
#define READ  0x13
#define WRITE  0x12
#define UNLOCK  0x14
#define IDWRITE  0x32
#define IDREAD  0x33
#define CLRRAM  0x54

//time and configuration registers
#define MILISECONDS_REGISTERS      0x00
#define SECONDS_REGISTER           0x01
#define MINUTES_REGISTER           0x02
#define HOURS_REGISTER             0x03
#define DAY_REGISTER               0x04
#define DATE_REGISTER              0x05
#define MONTH_REGISTER             0x06
#define YEAR_REGISTER              0x07
#define STATUS_REGISTER            0x08
#define CALIBRATION                0x09

//alarm 0 Registers
#define ALARM0_SECONDS_REGISTER           0x0C
#define ALARM0_MINUTES_REGISTER           0x0D
#define ALARM0_HOURS_REGISTER             0x0E
#define ALARM0_DAY_REGISTER               0x0F
#define ALARM0_DATE_REGISTER              0x10
#define ALARM0_MONTH_REGISTER             0x11

//alarm 1 Registers
#define ALARM1_SECONDS_REGISTER           0x12
#define ALARM1_MINUTES_REGISTER           0x13
#define ALARM1_HOURS_REGISTER             0x14
#define ALARM1_DAY_REGISTER               0x15
#define ALARM1_DATE_REGISTER              0x16
#define ALARM1_MONTH_REGISTER             0x17


//test diodes connections
sbit OSCON at LATA0_bit;
sbit OSCON_Direction at TRISA0_bit;

// RTC5 click module connections
sbit Chip_Select at LATC4_bit;  // this is where Chip_Select is fully defined
sbit Chip_Select_Direction at TRISC4_bit; // this is where Chip_Select_Direction is fully defined

unsigned char read_array[16];
//unsigned char date_array[16];

unsigned char txtSec[12];
unsigned char txtMin[12];
unsigned char txtHour[12];
unsigned char hours;
unsigned char minutes;
unsigned char seconds;


// RTC Functions

//clear RTCC and SRAM memory
void Clear(void)
{
   //Clear RTCC memory
   int i;
  for(i=0;i<0x20;i++)
  {
    Chip_Select = 0;
    SPI1_Write(WRITE);
    SPI1_Write(i);
    SPI1_Write(0x00);
    Chip_Select = 1;
    delay_us(1);
  }
  //Clear SRAM memory
  Chip_Select = 0;
  SPI1_Write(CLRRAM);
  Chip_Select = 1;
  delay_us(1);
}

  void Start_RTC(void)
{
  //buffer seconds register
  unsigned char temp;
  Chip_Select = 0;
  SPI1_Write(READ);
  SPI1_Write(SECONDS_REGISTER);
  temp =  SPI1_Read(0);
  Chip_Select = 1;
  delay_us(1);

  //set ST bit
  Chip_Select = 0;
  SPI1_Write(WRITE);
  SPI1_Write(SECONDS_REGISTER);
  SPI1_Write(temp|0x80);
  Chip_Select = 1;
  delay_us(1);

  temp = 0;
 //check if oscillator is running
while(temp&0x20 == 0)
  {
  Chip_Select = 0;
  SPI1_Write(READ);
  SPI1_Write(DAY_REGISTER);
  temp =  SPI1_Read(0);
  Chip_Select = 1;
  delay_us(1);
  }
OSCON = 1; //light up OSCON diode

  //set VBATEN bit
  Chip_Select = 0;
  SPI1_Write(WRITE);
  SPI1_Write(DAY_REGISTER);
  SPI1_Write(temp|0x08);
  Chip_Select = 1;
  delay_us(1);
}

// Set RTC time
void SetTime(int seconds, int minutes, int hours) {

   // Write seconds into RTC
  Chip_Select = 0;
  SPI1_Write(WRITE);
  SPI1_Write(SECONDS_REGISTER);
  SPI1_Write(seconds);
  Chip_Select = 1;
  delay_us(1);

  // Write minutes into RTC
  Chip_Select = 0;
  SPI1_Write(WRITE);
  SPI1_Write(MINUTES_REGISTER);
  SPI1_Write(minutes);
  Chip_Select = 1;
  delay_us(1);

    // Write hours into RTC
  Chip_Select = 0;
  SPI1_Write(WRITE);
  SPI1_Write(HOURS_REGISTER);
  SPI1_Write(hours);
  Chip_Select = 1;
  delay_us(1);
}


// Read time from the RTC
void ReadTime() {
  Chip_Select = 0;
  SPI1_Write(READ);
  SPI1_Write(SECONDS_REGISTER);
  read_array[0] = SPI1_Read(0);      // Read seconds    terzo campo
  read_array[1] = SPI1_Read(0);      // Read minutes    secondo campo
  read_array[2] = SPI1_Read(0);      // Read hours      primo campo visualiizato
  Chip_Select = 1;
  delay_us(1);
}

// Format time
void FormatTime() {
  // Format seconds, minutes and hours
  read_array[0] = Bcd2Dec(read_array[0] & 0x7F);
  read_array[1] = Bcd2Dec(read_array[1] & 0x7F);
  read_array[2] = Bcd2Dec(read_array[2] & 0x7F);

  // Convert seconds, minutes and hours to string
  ByteToStr(read_array[0], txtSec);
  ByteToStr(read_array[1], txtMin);
  ByteToStr(read_array[2], txtHour);

  // Trim leading spaces
  Ltrim(txtSec);
  Ltrim(txtMin);
  Ltrim(txtHour);
}

void Tone() {
  Sound_Play(450, 200);   // Frequency = 659Hz, duration = 250ms
}


  void main () {
  
  // Setting output frequency to 140MHz
  PLLFBD = 70;             // PLL multiplier M=70
  CLKDIV = 0x0000;         // PLL prescaler N1=2, PLL postscaler N2=2
  
  // Set all pins as digital
  ANSELA = 0x00;           // Convert all I/O pins to digital
  ANSELB = 0x00;
  ANSELC = 0x00;
  ANSELD = 0x00;
  ANSELE = 0x00;
  ANSELG = 0x00;



  Sound_Init(&PORTD, 3);
  Delay_ms(3);
  Tone();
  Delay_ms(3);
   
  PPS_Mapping(100, _INPUT,  _U1RX);              // Sets pin RP100  RF4 to be Input, and maps U1RX to it
  PPS_Mapping(101, _OUTPUT, _U1TX);              // Sets pin RP101  RF5 to be Output, and maps U1TX to it
  
  UART1_Init(115200);              // Initialize UART module at 115200 bps
  Delay_ms(3);                 // Wait for UART module to stabilize
  
//Unlock_IOLOCK();
  PPS_Mapping_NoLock(98, _OUTPUT, _SDO1);     // Set pin MISO RF2 to be Output, and map SD01 to it
  PPS_Mapping_NoLock(79, _OUTPUT, _SCK1OUT);  // Set pin SCK RD15 to be Output, and map SCK to it
  PPS_Mapping_NoLock(104, _INPUT,  _SDI1);     // Set pin MOSI RF8 to be Input,  and map SDI1 to it
//Lock_IOLOCK();

  Delay_ms(50);

Chip_Select_Direction = 0;         // Set chip select pin direction
/*LATC4_bit=1;*/
Chip_Select = 1;
delay_us(1);


OSCON_Direction = 0;
OSCON = 0;
 delay_us(1);
  
  // Initalize SPI module
SPI1_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_1, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE);
 //SPI1_Init();
SPI_Set_Active(&SPI1_Read, &SPI1_Write);
  

  // Set time
  Clear();
  Delay_ms(50);
  
  SetTime(0x00,0x00,0x05);
  Delay_ms(500);
  
  //seconds = 0x00;
  
Chip_Select = 0;
/*SPI1_Write(WRITE);*/
/*SPI1_Write(SECONDS_REGISTER);*/
SPI1_Write (0b1000000 | seconds);
Chip_Select = 1;
  
  Delay_ms(500);                 // Wait for rtc module to stabilize*/
  
  Start_RTC();

  while(1){
    ReadTime();                      // Read time
    FormatTime();                    // Format time
    //DisplayTime();                   // Display time
    

      //IntToStr(0,txtHour);
      UART1_Write_Text(txtHour);
      UART1_Write_Text(";");
      UART1_Write_Text(read_array[2]);
      UART1_Write_Text(";");
      
      //IntToStr(0,txtMin);
      UART1_Write_Text(txtMin);
      UART1_Write_Text(";");
      UART1_Write_Text(read_array[1]);
      UART1_Write_Text(";");
      
      //IntToStr(0,txtSec);
      UART1_Write_Text(txtSec);
      UART1_Write_Text(";");
      
      UART1_Write_Text(read_array[0]);
      UART1_Write_Text(";");
    
      UART1_Write_Text("Time0.1");
      UART1_Write_Text(";");
      UART1_Write(13);       //  new line
      UART1_Write(10);       // return
    
  Delay_ms(500);

  }
}



this is what i visualize in the terminal

Code:
0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;

0;N;0;M;0;L;Time0.1;


still the values of hours minutes and seconds are 0


because i am not sure if the SPI1 is working , according to the Mc i mapped
the pin of SPI

Code:
//Unlock_IOLOCK();
  PPS_Mapping_NoLock(98, _OUTPUT, _SDO1);     // Set pin MISO RF2 to be Output, and map SD01 to it
  PPS_Mapping_NoLock(79, _OUTPUT, _SCK1OUT);  // Set pin SCK RD15 to be Output, and map SCK to it
  PPS_Mapping_NoLock(104, _INPUT,  _SDI1);     // Set pin MOSI RF8 to be Input,  and map SDI1 to it
//Lock_IOLOCK();


Andre

regarding what you suggetsed me

is it right how I did ?

Code:
SetTime(0x00,0x00,0x05);
  Delay_ms(500);
  

  
Chip_Select = 0;
SPI1_Write (0b1000000 | seconds);
Chip_Select = 1;
 

You don`t need to clear the RTCC registers forcing them to "Zero", even because some of these addresses are not supposed to accept this value (e.g Month[1..12]). Another point is that you are setting bit 6 instead of bit 7 on the above snippet. In addition, you are perhaps not giving sufficient time to CS turn stable, consider adding a NOP() instruction right after each change in the state of that pin.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top