- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello sir ,
I have cy8ckit -049-42xx Psoc 4 prototyping KIt. I am begainer, recentally I have done LED blinking Project.. now I want to do some more projects. I have Ds1307 real time clock Ic. I want to interface RTC with psoc 4
My task
LED will turn on for 1 houre
LED will turn off for 10 minute
LED will turn on for 20 seconad
I looked component data log But there no RTC component. I don't understand how to make Top design on psoc creator
could someone help me please ..........!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you do not understand how to write C then google "C programming tutorial",
there are tons of online courses, many free, to do this. Here is an example of some
hits -
http://www.cprogramming.com/tutorial/c-tutorial.html
https://www.youtube.com/watch?v=2NWeucMKrLI
If you want to hire help to write your program and do your design, consider CyPros,
Cypress design partners -
http://www.cypress.com/?id=1389
If you know how to write C then let forum know where you specifically need
help in your code.
I looked component data log But there no RTC component. I don't understand how to make Top
design on psoc creator could someone help me please ..........!
You wire up your 1307 to the I2C pins you defined on PSOC then in code
send 1307 command to read years register for example, and take the return
data now in PSOC to operate on. You do not need anything more on your
schematic. Other than a pin to drive LED and an LED connected to pin.
There is an example project using I2C to communicate to a device, read and write
it, over I2C. On Creator start page "Find Example Project"
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vead did you not understand what I was telling you a few post back. You can do this without any C code just using the DS1307 pin 7 and PWM components I think the max would be 2 PWM components. Just send the 1hz signal from the DS1307 pin 7 to the 4200 board and then you can use the PWM TC to light your led and it will be at 10 minutes and you can control the off times also. And the 2 sec on time and you would not need any code at all. You may need to feed the outputs into an OR gate to use just one led. But it will work.. Have you looked at the Psoc Ble 100 projects in 100 days example 33 it shows how to use a watch dog timer for a RTC. You may be able to use some of that code for your project
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello mr. Bob
I read your previous post . I have questions . can we set alarm for minute , for hours,for months , for years using two pwm components ? if yes then I will follow your advice
Mr. Dana
I know little bit about c programming, I looked many sample example. I am having problem to understand following sample code. there is time array. but I don't understand I don't understand how does time array used in that c program. I know I am not using LCD. I just need to set alarm using RTC
/* ========================================
*
* Copyright YOUR COMPANY, THE YEAR
* All Rights Reserved
* UNPUBLISHED, LICENSED SOFTWARE.
*
* CONFIDENTIAL AND PROPRIETARY INFORMATION
* WHICH IS THE PROPERTY OF your company.
*
* ========================================
*/
#include <project.h>
#include <stdio.h>
#include "DS1307.h"
#define ADDR 0x68
#define SET_TIME 1
uint8 wrBuff[9] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
int main()
{
uint32 rdStatus = 0;
uint32 wrStatus = 0;
uint32 nTime = 0;
uint8 rdBuff[16];
CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */
LCD_Start();
LCD_PrintString("Hello");
I2CM_Start();
// SetTimeArray(&wrBuff[1], 0x00104500, 0x02131209, (DS1307_ST_12HR|DS1307_ST_PM|DS1307_ST_SQOUT_1HZ) );
SetTimeArray(&wrBuff[1], 0x00054000, 0x01131215, (DS1307_ST_12HR|DS1307_ST_PM|DS1307_ST_SQOUT_1HZ) );
CyDelay(200);
// Set time function, uncomment to set time.
// wrStatus = I2CM_I2CMasterWriteBuf(ADDR, wrBuff, 9, I2CM_I2C_MODE_COMPLETE_XFER);
CyDelay(20);
;
for(;;)
{
I2CM_I2CMasterClearStatus();
wrStatus = I2CM_I2CMasterWriteBuf(ADDR, wrBuff, 1, I2CM_I2C_MODE_COMPLETE_XFER);
CyDelay(20);
wrStatus = I2CM_I2CMasterStatus();
I2CM_I2CMasterClearStatus();
rdStatus = I2CM_I2CMasterReadBuf(ADDR, rdBuff, 8, I2CM_I2C_MODE_COMPLETE_XFER);
CyDelay(20);
rdStatus = I2CM_I2CMasterStatus();
LCD_Position(0,0);
LCD_PrintString(GetTimeString(rdBuff, (DS1307_TIMEDATE2|DS1307_AMPM)));
LCD_Position(1,0);
LCD_PrintString(GetTimeString(rdBuff, DS1307_MDY));
nTime = GetSeconds(rdBuff);
LCD_Position(1,9);
LCD_PrintInt16((uint16)(nTime >> 😎 );
LCD_Position(1,13);
LCD_PrintInt8((uint8)(nTime & 0x00FF));
CyDelay(500);
/* Place your application code here. */
}
}
/* [] END OF FILE */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The time array, in this case rdBuff, reads the data from the 1307 via
the I2C connection. The data is read byte for byte, 8 bytes, and is
formatted within the bytes per 1307 datasheet memory map (the
data PSOC reads into rdBuff) -
The functions/code meh has written in DS1307.c then process the bytes in edBuff to extract time, day, etc.
per the formatting above that now resides in rdBuff.
Your question - I read your previous post . I have questions . can we set alarm for minute , for hours,for months , for years using two pwm components ?
By polling the DS1307 and some C code you can set alarms in C code based on time, date. So no, you
do not need PWMs for this, the DS1307 data being read into rdBuff and then extracted via meh
C code would create these alarms. In C code you would create tests comparing the alarm settings
to what was read from the DS1307.
The timArray is used to initialize the 1307, first time you power it up it does not
"know" what time/date is, so you need to init it.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vead I thought that you just wanted to have an indication at 1 hour turn led on then turn led off for 10 minutes and then turn it on again for 20 sec. That was what was stated in the first post. My solution would still work for any tine as the PWM would run in a contentious mode. But if you want to set the alarms for other times then you would need a software solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I did some search on internet. and I tried to write program myself . but I am not sure that I am going on right track ?
Set alarm for 10 second (automatically turn on LED for 10 second )
C Program
void I2C_Init()
{
SDA = 1;
SCL = 1;
}
void I2C_Start() // start I2C
{
SDA = 0;
SCL = 0;
}
I2C_write() // send data to Ds1307
{
I2C_write(0xD0); // address of the DS1307 )
I2C_write(0x00); // address of seconds register
I2C_write(0x10); // 10 data as 10 second
}
void I2C_Ack()
{
SDA = 0;
SCL = 1;
SCL = 0;
SDA = 1;
void I2C_Stop() // stop I2C
{
SCL = 0;
SDA = 0;
SCL = 1;
SDA = 1;
}
void I2C_Start()
{
SDA = 0;
SCL = 0;
}
I2C_read()
{
I2C_write(0xD1); // address of the DS1307 )
I2C_write(0x00); // address of seconds register
I2C_write(0x10); // 10 data as 10 second
}
void I2C_Nak()
{
SDA = 1;
SCL = 1;
SCL = 0;
SDA = 1;
}
void I2C_Stop() // stop I2C
{
SCL = 0;
SDA = 0;
SCL = 1;
SDA = 1;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Open up Creator, use "Find Example Project", and look at how an
I2C project is done.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok I saw some project after that I did some work
start I2C
start ds1307
write address of ds1307
write address of second register
werite data (10 second )
read the address of ds1307
read the address of seond register
read data (10 second )
turn on LED for 10 seconds
#include <device.h>
#include "utils.h"
void I2C_Init(void)
{
// Start the I2CHW
I2CHW_Start();
// Enable the I2C interrupt
I2CHW_EnableInt();
// Enable I2CHW module in Master configuration
I2CHW_EnableMstr();
}
/* Start RTC */
RTC_Start();
RTC_WriteReg(0x07);
//Word Address from where data has to be written
SetTime.Address = 0x00;
// This function is used to set the time and date.
// Set the seconds (BCD format)
SetTime.Seconds = 0x10;