Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by mityeltu

  1. ok. lots of reading there. I'll pry into that tonight.


    As I see it, I need to send a minimum of 3 bytes to the slave (slave address, slave internal register address, data). Is it possible to send just one byte (slave address) just for the sake of checking communications? For instance, can I do the following:



    send_byte(slave address);



    Since the slave SHOULD have the SSPIF flag set when the address mathces (right?), I would imagine i could just have my slave in an infinite loop waiting for the SSPIF flag to set and then toggle an LED. Is that possible? I ask because that's what I'm trying to do and it is not working.


    The master is communicating (checked on scope), but the slave isn't responding.

  2. I'm attempting to create a slave module with a 16f1519 using 7-bit addressing. I'm confused by the datasheet. It appears that the R/W bit of the 7-bit address is bit 0, but I can't find that defined anywhere.


    If I read this right, then after the start condition is detected, the master clocks out the 7 address bits. I got that part, but the data sheet sates that the last bit clocked out (bit 0) is ignored. Technically it states that this bit is unused and is a 'don't care' condition in 7-bit slave addressing. So, if I am using 7-bit addressing, how to I tell the slave that the next byte sent is data to be received vs address to be read? Is this something that is handled as part of the slave firmware? That is, the address I create for the slave includes a bit that tells the controller if it is a read vs write operation? If that's the case, it sounds like it is really a 6-bit address with an R/W bit.


    What am I missing?

  3. /*
    * 18f2525
    * 8MHz internal oscillator
    * UART Communcations with wTerm on PC
    * MAX232N
    #include <system.h>
    #include <stdlib.h>
    #include <string.h>
    #include <lcd_driver.h>
    #include <stdio.h>
    #pragma CLOCK_FREQ 8000000
    #define BAUDRATE 9600
    #define _XTAL_FREQ 8000000	//	Hz
    //subroutine declarations
    void setup(void);
    void InitUART(void);
    void UART_SendByte(unsigned char);
    void UART_SendString(const unsigned char*);
    unsigned char UART_ReceiveByte(void);
    unsigned char flags, rx_dat;
    void main()
    	char str[4], a = 0;
    	osccon = 0x72;	//	8MHz internal osc
    	while(!test_bit(osccon,2)){}	//	wait till osc stable
    	UART_SendByte(0x0d);	//	carriage return
    	UART_SendByte(0x0a);	//	line feed
    			flags.0 = 0;
    			pir1.RCIF = 0;
    void setup()
    	intcon = 0xc0;	//	interrupts off
    	intcon2 = 0x80;	//	pullups disabled
    	rcon = 0x80;	//	interrupt priority enabled
    	pie1.RCIE = 1;	//	rx interrupt enabled
    	ipr1.RCIP = 0;	//	rx int low priority
    	ccp1con = 0x00;	//	cap/comp disabled
    	ccp2con = 0x00;
    	sspcon1 = 0x00; //  spi disabled
    	adcon0 = 0x00;	//	adc disabled
    	adcon1 = 0x0f;	//	all digital i/o
    	cmcon = 0x07;	//	comparaor disabled
    	cvrcon = 0x00;	//	comparator volt ref disabled
    	hlvdcon = 0x00;	//	hi/lo volt det disabled
    	trisa = 0x00;
    	lata = 0x00;
    	trisb = 0x00;
    	latb = 0x00;
    	trisc = 0x00;
    	latc = 0x00;
    	//flags = 0;
    void InitUART()
    	trisc.6 = 1;	//	TX pin
    	trisc.7 = 1;	//	RX pin
    	spbrg = ((_XTAL_FREQ/16)/BAUDRATE) - 1;
    	txsta.BRGH = 1;	//	fast baudrate
    	txsta.SYNC = 0;	//	asynchronous
    	rcsta.SPEN = 1;	//	enable serial port pins
    	rcsta.CREN = 1;	//	enable reception
    	rcsta.SREN = 0;	//	single receive disabled
    	pie1.TXIE = 0;	//	disable tx interrupt
    	pie1.RCIE = 1;	//	enable rx interrupt
    	txsta.TX9 = 0;	//	8-bit transmission
    	rcsta.RX9 = 0;	//	8-bit reception
    	txsta.TXEN = 0;	//	reset transmitter
    	txsta.TXEN = 1;	//	enable transmitter	
    void UART_SendByte(unsigned char dat)
    	while(!pir1.TXIF);	//	wait till last transmission finishes
    	pir1.TXIF = 0;
    	txreg = dat;
    void UART_SendString(const unsigned char* str)
    	while(*str) UART_SendByte(*str++);
    unsigned char UART_ReceiveByte(void)   // Reads a character from the serial port
    	if(rcsta.OERR) // If over run error, then reset the receiver
    		rcsta.CREN = 0;
    		rcsta.CREN = 1;
    	return RCREG;
    //------------------------------------------------------------------		interrupt routines
    void interrupt_low()	//low priority ISR
    	if(pir1.RCIF)  // If UART Rx Interrupt
    		pir1.RCIF = 0;
    		flags.0 = 1;
    		if(rcsta.OERR) // If over run error, then reset the receiver
    			rcsta.CREN = 0;
    			rcsta.CREN = 1;
    		rx_dat = rcreg;

    This is the first time I have tried to send data to a pc using the UART. I have done this between PICs and use it (sort of) to save data to an SD card, but have never sent data to or received data from the PC. That being said, I have managed to get it working pretty well. Very few GOOD working examples on the net. Anyway, I seem to have a small issue that I can't resolve. The pic sends 2 strings at the beginning of operation so I know it's alive. Then it just sits and waits to receive data that it will echo bach to the PC. No biggie. Problem: every time the pic starts (and only when it starts) it send a null character to the pc. I am using Realterm as my pc side terminal. Code is below (or above -- not sure why it won't put the code where it makes sense).


    Anyway, does anyone have an idea why I keep getting the null at the start?


  4. Ok, well, all that not withstanding, I purchased a 4x40 lcd module and have it working with the existing boostC library. I am able to use all 4 lines and all 40 characterws per line. That was all I wanted to know if it could do. All the other stuff is just cannon fodder.


    It seemed to me like a pretty straight forward question but I do realize now that I was incorrectly using "compiler" when I should have been using "library". Anyway, the issue is resolved and I have my answer. I can use the existing boostC library on the 4x40 lcd module.


    I apologize for the confusion.


    Thank you for all your input.

  5. I still don't think we're speaking the same language.


    I realize that I could probably build my own library. I don't want to do that if I don't HAVE to (why recreate the wheel if there's a perfectly usable wheel to be used?).


    So, the question is not about the PIC or the LCD controller. The question is about the boostC compiler. Is there a limit to what the boostC compiler can do with regards to the lcd library? in other words, when I use the command lcd_gotoxy(0,3) am I going to get an error because the library has no idea how to handle a 4 line lcd?


    That being said, I guess there IS a question to be had regarding the lcd controller: perhaps the boostC compiler will not generate an error with the code I suggested above but will simply not compile it in a way that the lcd controller will understand, again due to a misunderstanding that the boostC compiler has regarding a 4 line lcd.


    Is my question making any sense?

  6. Well, what I mean is this. Is there a limitation to the size (lines/characters) that can be used when using BoostC or BoostC++ as the compiler? I have another compiler that is limited to no more than 20 characters and no more than 4 lines. So, if I want to use a 4x40 LCD, I can't use that particular compiler as it does not support the number of characters I need. Now, that is based on the library for the compiler, so it might work fine if I built my own library, but I haven't tried that. Plus, I woudl really ratehr use BoostC++.


    Does that make more sense?

  7. I have run into this in the past, but I can't remember exectly what I did to fix it. I am finding that the delay_s(4) gives me exactly half the time I specified. I seem to remember that I fixed this by making sure the _XTAL_FREQ was properly defined and that the osccon register was properly set. I have both set for 8MHz. I also have made sure that the configuration bits are set correctly for internal oscillator. but I am still getting 2 seconds delay from the instruction above. Is there something else I need to do? hat have I missed? I'm using pic18f4620 if it makes any difference.

  8. I am working on some math for PIC16F1519. I found a forum (this thing won't let me paste the link or the code in here (I don't understand that, but whatever). If you search Googe for "lprintf format sourceboost", the first link takes you to the code I am referring to.


    Anyway, the problem is not with the code (I don't think). I have added flot.h to the list of includes, but when I try to build the project I get a list of erros : Unresolved external function: 'float32_to_int32(float)'. I get errors likke this for all the functions I'm calling from the float header file. What do I need to do to fix this? I thought including the header file was all I needed to do to be able to use the included functions.


    I am trying to get the subject chip to work, but the BoostC compiler keeps complaining about the configuration buts I have.


    This above is what I have (this crazy forum won't let me put the code anywhere but at the top of this.... why doesn't anything ever work right??????)


    Any way, the error has to do with _VCAPEN_OFF parameter. It keeps complaining that this is an unknown identified and an invalid operand. I looked in the .h file for the 16f1519 and this item is listed for config2. I tried includeing PIC16F1519.h and all that did was throw a huge number of errors for having variables that already exist.


    Can anyone explain what I have done wrong here?


    Just so you know, there is NOTHING in the main program except



  10. Has anyone used the API to create their own plugins for sourceboost? I was using the simulator to test a program I am working on that uses timer 3 on an 18f platform and realized nothing was working. I checked the ide manual and found that timers 1, 2 and 3 are not implemented on the 18f series. Well, I can't use timer 0, so I though maybe I would make my own plugin. I've never done this before, so any help anyone out there might have would be greatly appreciated.


    Does anyone have an example of one they have written so I can have a framework to start with?



  11. Ya know, I try my best to learn things from the net and usually come up craps. I found the same document and read through it. That's how I came up with the code I had. I appreciate what you say, and if I knew what I don't know that would make things a little easier maybe, but when I don't know what I don't know, I ask questions of people who might know - like folks on this forum. Sadly, I typically get snarky responses like yours rather than actual useful information or assistance in understanding what I don't currently understand. Thanks for sarcasm.

  12. OK, more on this wierdness.


    Apparently you can't just send the custom character to the lcd. it has to follow either the lcd_datamode() command or other formatted text. I didn't know this until after I posted the above, so please bear with me as I learn how this thing works.


    So, if you need to send the custom character FIRST, do this:

    lcd_datamode();//apparently needed so the lcd knows what to do next
    lcd_write(0x00);//send custom characte to lcd
    lprintf("wierd");//normal formatted text does not need the lcd_datamode() command

    However, if you are sending text and THEN send the custom charcater, you do NOT need the lcd_datamode() command:

    lprintf("wierd");//normal formatted text
    //NOTE: No lcd_datamode command is necessary here
    lcd_write(0x00);//send custom character to lcd
    lprintf("still wierd)";

    I have no explanation for this behavior. It is cumbersome and inconvenient and there is NO documentation on it anywhere. Either I am doing something wrong or this is a glitch in sourceboost. I suspect the latter.


    Anyway, hope this helps.

  13. Well, I can see that no one else apparently knows how to do this, or EVERYONE knows how and just doesn't care to help. I will assume the former.

    So, I searched and searched some more and found the attched pdf. Page 23 of the file here: http://www.mrc.uidaho.edu/mrc/people/jff/340/341/labs/lab6/Project6.pdf gives the framework instructions and the code below will generate a single 5x8 custom charcater that is stored in cgram memory location 0. I tried to attach just page 23, but the file size limit is so small that even a single page was too large to post here (crazy). In case the link gets broken, the pdf is from Digilent and has the title "Handshaking and LCD Control with the Cerebot MX7ck".

    lcd_funcmode();//command mode
    lcd_write(0x40);//set cgram address to 0
    lcd_datamode();//set to send character byte data
    lcd_write(0x0a);//byte 0
    lcd_write(0x15);//byte 1
    lcd_write(0x0a);//byte 2
    lcd_write(0x15);//byte 3
    lcd_write(0x0a);//byte 4
    lcd_write(0x15);//byte 5
    lcd_write(0x0a);//byte 6
    lcd_write(0x15);//byte 7
    lcd_gotoxy(0,0);//leave function mode and go home

    This will store the character in the LCD CGram. To display the character, simply use the lcd_write(address); command. For the above code it will be lcd_write(0x00);


    I hope this helps others who have been looking for a way to create custom characters in sourceboost. From the code, it should be evident how this process can be automated in a loop using an array and a pointer to the array. The address for the data is automatically incremented with each sucessive lcd_write command, so there is no need to keep up with that part of it (just like when you write characters to the display you don't have to constantly upddate the position).


    Good luck.

  14. I am struggling with how to get custom lcd characters written into my code. I have read the datasheet and understand (sort of) that I need to write the data into the cgram. But looking at the datasheet also seems to suggest I need to do the following:

    Clear RS & RW, set DB7 and set/clear DB6-DB0 to set the ddram address.

    Then I need to clear DB7 ad set DB6 and set/clear DB5-DB0 to send the cgram address.

    then I need to send the data that has my custum mapped character.


    To compound this, I am also in 4 bit upper mode. I'm lost with this.


    Is there anyone out there who has done this who is willing to post the code?

  15. @richardc: Yes, I have found that to be true. I have a much older laptop running XP and while still slower, it is infinitely faster than on the laptop with win7. I suppose part of it is the bloated nature of win7. I really don't like microshaft.


    @JorgeF: When I say "any real size" I mean a few kbytes. I have a couple of programs that might fill half the memory on a 18f452. Most only take a few hundred bytes. The few hundred byte programs still take minutes to compile. The larger programs take many minutes. I just hate the wait. I don't have time for that.


    I'll try turning off all the power saving features, though I think they are already turned off when on line power. I don't expect much change there. I probably need to get a clean build win7 disk rather than the toshiba duild. I suspect alot of fluff is running in the background that is getting in my way.

  16. OK. I left the reservation to attempt to find a more suitable compiler/tool suite to use on my laptop. I found one or 2 that worked but lacked the power I want/need for my work-related projects. That being said, I decided that maybe looking into a different laptop was the way to go. I am currently using a Toshiba P755-S5120 Laptop 15.6" (750 GB, Intel Core i7, 2.2 GHz, 8 GB) running Windows 7. This thing, as fast as it is, will not compile even the smallest of programs in less than a minute and if the program has any real size, it takes anywhere from 3 to 10. I don't have that kind of time to sit and wait for a program to compile that may not (very possibly) be entirely correct.


    So, all you guys out there who use BoostC or BoostC++ and use a laptop, what laptop are you using and do you have the same compile time issues I do on my laptop? In other words, what should I be looking for in a laptop that will allow me to run this the way it was intended to run?



  • Create New...