|
|
View previous topic :: View next topic |
Author |
Message |
timk
Joined: 03 Aug 2018 Posts: 11
|
Problems with I2C on dsPIC30F6015 |
Posted: Tue Aug 21, 2018 3:37 am |
|
|
Hello,
I got problems to send messages via I2C of the dsPIC30F6015.
I just want to get a really simple program to work.
Code: |
#use i2c(master,I2C1,stream=I2C_NFC)
...
while(1)
{
i2c_start(I2C_NFC);
i2c_write(I2C_NFC, 0xFF);
i2c_stop(I2C_NFC);
delay_ms(100);
}
|
The program is just a test program.
The compiler says """Error 12... Unknown identifier: I2C_NFC
I think is a small syntax-error.
Thanks in advance. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Tue Aug 21, 2018 4:15 am |
|
|
First question. What compiler version?. On very old compilers I2C streams didn't exist.
However assuming something from the last few years, what you post works:
Code: |
#include <30F6015.h>
#device ICSP=1
#use delay(crystal=20000000)
#FUSES NOWDT //No Watch Dog Timer
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT //No brownout reset
#use i2c(master,I2C1,stream=I2C_NFC)
void main()
{
while(TRUE)
{
i2c_start(I2C_NFC);
i2c_write(I2C_NFC, 0xFF);
i2c_stop(I2C_NFC);
delay_ms(100);
}
}
|
Compiles fine.
One thing that can happen, is a 'hidden' character. If you have typed a non displayable character in one of the I2C_NFC parts, then this would be the complaint you would get. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|