Jump to content

mityeltu

EstablishedMember
  • Content count

    85
  • Joined

  • Last visited

Community Reputation

0 Neutral

About mityeltu

  • Rank
    Regular
  • Birthday 02/08/1968

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Gender
    Male
  • Location
    Tennessee
  • Interests
    Communications
  1. What? "as a float 0x41bba752 = 0x4e83774f"?! Wait.... I'm going to go do some research on this.... I obviously missed something in C training. I'll have to get back to you on this. That makes absolutely no sens at all to me. In fact, at the moment, that seems like a complete contradiction. Not saying you're wrong. In fact, I'm saying you're probably right and I just don't understand. So, thank you for the correction, and I'm gonna go and relearn - or maybe just learn - what it is you;re talking about. Thanks.
  2. I'm not sure how that is really any different. If I take a floating point variable and shift in 0x41bba752 and take a second floating point variable and load it with 23.4567, do they not contain the same hex values? That is really confusing if they would not be the same. I understand what you mean about the integer type value being very large, but if the bits in a float variable loaded with 23.4567 are in the same order as the one loaded with 0x41bba752, why do they produce different values? Is it becuase of what you said above? "a float is a pointer... " So, somehow when a float is declared, the compiler knows to grab 4 bytes, but uses each byte differently than if the float is loaded with the same bit pattern in a different way? Why does that make any sense? Wait, is it backwards? If I shift in the bits in reverse byte order, wil I get the correct value in the float?
  3. The Union worked!! Thank you! I have no idea WHY it worked, but it worked. This is excellent! I now have a complete I2C LCD library that can receive any kind of variabel and display it on an LCD. Perfect! I would still love to hear why my original code does not do the same thing.
  4. I'll try both today. Can anyone explain why my code doesn't work? I realize that an int is only 2 bytes, but the fact is a float is 4 bytes and if I load a float with the value 23.4567, the hex value stored in the variable should be 0x41bba752 based in IEEE. So, if I shift those bits into the variable, why do I get such strange results? As I said, if I load the variable with 23.4567 and then use the method listed above, the LCD will have 23.4567 on it, but when I shift the bits into the variable and perform the above function, the LCD gives me nonsense. Is there a reason for this that I am not understanding?
  5. int i, f; float fnum = 0x41bba752; // this should be 23.4567 i = float32_to int32(fnum); lprintf("%d",i); lprintf("."); f = float32_to_int32(float32_mul(float32_sub(fnum,float32_from_int32(i)),10000)); lprintf("%d".f); I am attempting to recombine a set of 4 bytes sent via I2c into a floating point number. I can see the 4 bytes being transferred using a logic analyzer and they are correct for the number I am transferring, but I can't get the recombined number to diaply correctly, so I tried to just load the floating point number as a hex value and I get garbage on the LCD. Here's what I'm doing: see above (I guess - this thing never puts my code where I want it). Anyway, the LCD shows -23040.-1 which is obviously wrong. So, why am I gettign such garbage? Any ideas? If I use fnum = 23.4567, the LCD shows 23.4567. Maybe I did the conversion wrong, but Im pretty sure that 23.4567 = 0x41bba752.
  6. I2C Configuration

    Yeah, thanks. Thoght that might be the case. Sad. Would be a nice upgrade along with some sort of configuration bit editor. Would really make for a useful set.
  7. I have seen in the "Images" subdirectory in the Sourceboost directory that there are pictures of what appear to be configuration tools for I2C. Where is this tool located? Is this part of the simulator? I have not been able to find this anywhere. Can someone point me in the right direction? Thanks.
  8. I am trying to encapsulate 2 ports from 18F2620 into a single variable. What I want to be able to do is something like the following pseudocode variable ex_port = porta:portb // 16 bits of 2 ports in a single variable for (z = 0, z<16, z++) ex_port.z = 1 next z what I'm trying to do is to sequence through both ports as well as to be able to address each individual port pin wihtout having to first address the individual port. I hope that makes sense. Is there some way to bundle the ports together like this? Since boostc does not support bitfields, this becomes pretty large if I used a structure of bytes. I hope I'm not just making this way harder than it needs to be. Is there an easy way?
  9. I have been trying for the last couple of days to program the 18f24j11. I know there are some problems with the header file included in boostc, but I think I have fixed them. Section of header file is attached. However, fixing the header file doesn't fix the chip. I still have no life. Program is primitive, but I am just trying to get anything to work. I am using pickit2 to program the chip. No errors when programming. Is there anything you guys see that is wrong with the code/header? Is there some wierd way to program the chip that is different from other 18f chips? I am using 3.3v power supply, so I know that is not the issue. Any thoughts on this? PIC18F24J11.h.txt 18F24J11-3_3V.cpp
  10. I don't find a header file for the 18F45K50. I see one for the 18F45J50 and the 18F45K80 and K20, but not the K50. Are you sure you are not outside the applicable device list for sourceboost? Also, if you have selected the 18F45J50 as the target, it doesn't have any eeprom.
  11. //SLAVE CODE sspcon.CKP = 0; sspbuf = 22; sspcon1.WCOL = 0; sspbuf = 0x22; sspcon.CKP = 1; //MASTER CODE i2c_start(); i2c_write(i2c_slave_add | 0x01); // write to slave i2c_write(0x04); // write command "Read_Temp" //wait till sspbuf is full, then read out the data i2c_read(1); while(!sspstat.BF); UART_SendString(" Temp: "); t_dat = sspbuf; itoa(sspbuf,buff,10); // prepare for uart UART_Write_Text(buff); // send data to uart i2c_stop(); I have managed to get a master slave system working (mostly) with a pair of 16F1519 chips. I am certain the I2C is working as I am able to make an LED on the slave turn on/off and blink on command from the master. I am now trying to have the slave send data back to the master, but I'm not getting anything back. I have tried several arrangements on both the master and slave to get data back, biut nothing yet. Does anyone have a working snippet I can see on how the master sends to get the data and the slave responds to send the data? My code is below for anyone who wants to try their luck at deciphering my madness. Still not sure why the code always gets stuck at the top of this.
  12. Is there an easy way to set the configuration bits in the Sourceboost IDE? It might seem lazy, and maybe I've been spoiled by using MPLAB and Oshonsoft compilers as they have a nice module for setting the bits and generating the necessary code to include in the firmware. Is there anything like that in the Sourceboost IDE? I've looked but couldn't find anything. If not, is there an easy way to go about it? I've been using the meLABS meCongfi software to get the code close, but it still needs some tweeking after pasting and I'd like to just set it and forget. I know that once I have them set I can just copy/paste into new programs, but it really seems like there should be an easy way to get them set the first time. For anyone who is interested, I'm also working on a VB project to do this for a number of the chips that I use frequently. If anyone wants a copy, I'll post it here. And if there is a chip you want included, let me know and I'll try to code it in.
  13. Kindly disregard. I found the issue. One register from the original target is not named the same in the new (sspcon in the 1519 is named sspcon1 in the 2510). Sorry for the trouble.
  14. I have a working version (albeit very simple) of I2C that is targetted to 16f1519. I am attempting to port this over to 18f2510. I have verified that all the addresses in the i2c_driver.h match what is available on the 18f2510 (in other words, they are thye same as on the 16f1519). I have not changed anything in the header file. I have made sure that the config registers are correct for the new target. Problem, when I comile the program for the new target I keep getting the same error "failed to parse template arguments". As I understand this, it is telling me that somehow the arguments I am passing the templates are not correct for the target I have specified. That would indicate that the addresses are not correct, right? But they are. I ahve quadruple checked that. I have also verified that the mapped addresses are not outside the memory banks of the pic. I don't understand what to do from here. This should be an easy process, but I just don't know what to do. Can someone help me, please?
  15. After searching for a long time to find some decent working examples (that I could understand and follow), I managed to cobble together a very basic, simple working example of I2C master and slave. In additon, the master communicates via UART through MAX232 to the PC serial port. This is NOT elegent, but it does work. The hardware is a pair of 16F1519 with internal 8MHz oscillator, resistor on the SDA and SCL (I2C) buses are 4.7k to VCC (+5V), LED is on both master and slave at PORTD.1 (pin 14), MAX232 chip is interfaced per the attached drawing using info from the datasheet. Tha's all there is... well, and the serial cable which follows the attached drawing. (NOTE: if the picture of the connections is too small, I found it here: http://microcontrollerprojects00.blogspot.com/2012/03/pic-serial-communication-tutorial-uart.html The terminal program I am using is Realterm 2.0.0.70 - make sure you change the port to 9600 baud and set the port to whatever your serial port is (Port 1 on my laptop) and click "Change" I hope this helps others. Happy coding, mit 16F1519_I2C_Master.cpp 16F1519_I2C_Slave.cpp
×