Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

BoostC strangeness

Status
Not open for further replies.

futz

Active Member
Hi guys. After a long break from it I'm back tinkering with MCUs.

I'm trying to compile a program with BoostC and getting bogus error messages.
bleh.jpg
The errors follow that pixel() function when I move it elsewhere in the source file, so it isn't being caused by something above it.

Here's the prototype line from the header file:
Code:
void pixel(unsigned char, unsigned char, unsigned char);

I seem to have some vague memory of having this problem back when I first started using BoostC, and solving it. But it's gone now. :D

This code compiles correctly on another compiler (for another MCU).
 
Oh try this:
(as the prototype declaration at the top or in header)
Code:
void pixel(unsigned char x, unsigned char y, unsigned char color);
 
Last edited:
Here's the entire header file:
Code:
#include <system.h>
#pragma	CLOCK_FREQ	8000000
#pragma DATA    _CONFIG1H, _INTIO2_OSC_1H
#pragma DATA    _CONFIG2H, _WDT_OFF_2H
#pragma DATA    _CONFIG3H, _MCLRE_ON_3H
#pragma DATA    _CONFIG4L, _LVP_OFF_4L

#define CS      portb.0
#define DATACHAR    portb.1
#define SCLK    portb.2
#define SDATA   portb.3
#define RST     portb.4

void update(void);
void line(int,int,int,int,unsigned char);
void cls(void);
void lcd_init(void);
void lcd_reset(void);
void sendbyte(unsigned char);
void lcd_send(unsigned char, unsigned char);
void pixel(unsigned char, unsigned char, unsigned char);
 
And here is the entire source file. I know that 864 byte frame buffer won't work on a 18F1320 - I just wanted to do a test compile before I figure out what to do about that (might end up moving to a bigger PIC):
Code:
#include "7110_lcd.h"

int start,count,result,done = 0;
static unsigned int buffer = 0;
char number[] = "                ";
unsigned char framebuff[864];

void main()
{
    unsigned char x,y;
    osccon = 0x72;          //set int osc to 8MHz
    trisb = 0;
    adcon1 = 0b01111111;    //all digital
    while(1){
        for(x=10;x<36;x++){
            for(y=10;y<36;y++){
                pixel(x,y,1);
            }    
        }
        delay_s(1);
        cls();
    }    
}

void update(void){      //display frame buffer
    unsigned char i,x,outbyte,page;
    int count = 0;
    page = 0xb0;            //page address variable
    for(x=0;x<8;x++){
        lcd_send(page,0);       //set page address
        lcd_send(0x11,0);       //set column address
        lcd_send(0x02,0);
        for(i=0;i<0x60;i++){    //display a row
            outbyte = framebuff[count++];
            lcd_send(outbyte,1);
        }
        page++;
    }
}           

void lcd_init(void){
    DATACHAR = 1;
    delay_ms(2);
    lcd_reset();
    lcd_send(0xa6,0);   //Display: Normal   
    lcd_send(0xA3,0);   //LCD Bias Settings: 1/7
    lcd_send(0xA1,0);   //ADC Selection: Reverse
    lcd_send(0xC0,0); //Common Output: Normal Direction
//    lcd_send(0xC8,0); //Common Output: Upside Down
    lcd_send(0x22,0);   //Set the V5 output Voltage
    lcd_send(0x81,0);   //set Electronic Volume - brightness
    lcd_send(0x2f,0);   
    lcd_send(0x2E,0);   //Power Controller Set: Booster circuit: ON/Voltage regulator circuit: ON/Voltage follower circuit: OFF
    lcd_send(0x2F,0);   //Power Controller Set: Voltage follower circuit: ON
//    lcd_send(0xE3,0);   //Non-OPeration Command
//    lcd_send(0x40,0);   //Set the start line
    lcd_send(0xAF,0);   //LCD On
    lcd_send(0xA4,0);   //Display All Points: NORMAL
    cls();
}

void cls(void){
    unsigned char i,x,line;
    int j;
    line = 0xb0;                //page address variable
    for(x=0;x<9;x++){
        lcd_send(line,0);       //set page address
        lcd_send(0x11,0);       //set column address
        lcd_send(0x02,0);
        for(i=0;i<0x60;i++){    //write zeros to display RAM
            lcd_send(0x00,1);
        }
        line++;
    }
    for(j=0;j<865;j++)
        framebuff[j] = 0;
}

void lcd_send(unsigned char cmd, unsigned char type){
    if(type)
        DATACHAR = 1;
    else
        DATACHAR = 0;
    CS = 0;
    sendbyte(cmd);
    CS = 1;
}    

void sendbyte(unsigned char data){
    char x;
    for(x=0;x<9;x++){
        SCLK = 0;
        SDATA = 0;
        if(data & 0x80)
            SDATA = 1;
        SCLK = 1;
        data <<= 1;
    }
}
        
void lcd_reset(void){
    CS = 1;
    delay_ms(2);
    RST = 1;
    delay_ms(2);
}

void pixel(unsigned char x, unsigned char y, unsigned char color)
{
    unsigned char temp,readtemp;
    char bit,div;
    int offset;
    div = y >> 3;
    offset = div * 96 + x;
    bit = (y - (div << 3));
    temp = 1 << bit;
    readtemp = framebuff[offset];
    if(!color)
        y = readtemp & ~temp;
    else
        y = readtemp | temp;
    framebuff[offset] = y;
}
 
Last edited:
Fixed.. you cant use the name "bit"

try this
Code:
void pixel(unsigned char x, unsigned char y, unsigned char color)
{
    unsigned char temp,readtemp;
    char [B]mbit[/B], div;
    int offset;
    div = y >> 3;
    offset = div * 96 + x;
    [B]mbit [/B]= (y - (div << 3));
    temp = 1 << [B]mbit[/B];
    readtemp = framebuff[offset];
    if(!color)
        y = readtemp & ~temp;
    else
        y = readtemp | temp;
    framebuff[offset] = y;
}

I guess in BoostC "bit" is a type

You see posting full code helped a great deal :D
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top